Reputation: 695
In my rails app, I am trying to use the Google Maps embedded API.
Everthing is working fine when i use:
<iframe width="500" height="300" frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key=AIzaSyDBvzq5WsidARhAZ0821MB1iAMTPnHiamI&q=3177 shawnee ct,cameron park,ca,95682" allowfullscreen>
</iframe>
This works and the map displays. But that is with explicitly saying the address.
My Model has a :full_address
field and a :longitude
and :latitude
fields.
I am trying to do the following:
<iframe width="500" height="300" frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key=AIzaSyDBvzq5WsidARhAZ0821MB1iAMTPnHiamI&q=#{@job.jobsite.full_address}" allowfullscreen>
</iframe>
But its not recognizing my rails object of @job.jobsite.full_address
. I already know that there is an address stored there, and I tested it with the static map API and everything worked fine.
But when i try to render the map it gives me the error:
The Google Maps API server rejected your request. Invalid request. Invalid 'q' parameter.
Can anyone tell me why @job.jobsite.full_address
is not working in side that url I am providing?
Upvotes: 0
Views: 426
Reputation: 677
Kindly replace your location with ruby tag
<iframe width="500" height="300" frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key=AIzaSyDBvzq5WsidARhAZ0821MB1iAMTPnHiamI&q=<%[email protected]_address%>" allowfullscreen>
Upvotes: 3