1

I've seen this asked before but do not see an answer that will help resolve my problem.

Here is the map embed code:

<iframe style="border: 0;" src="https://www.google.com/maps/embed/v1/search?key=AIzaSyD500KZjSof98vSBhKTytpoP3rlJi69WXM=senior+assisted+care+near+me&zoom=9" width="600" height="450" frameborder="0" allowfullscreen="allowfullscreen"></iframe>

I have this embedded on a Wordpress website.

Does anyone know why I would be getting this error?

error: Google Maps Platform rejected your request. Invalid request. Missing the 'q' parameter

4

2 Answers 2

2

Your are getting the error: Google Maps Platform rejected your request. Invalid request. Missing the 'q' parameter because you don't have the q= parameter in the URL:

<iframe style="border: 0;" src="https://www.google.com/maps/embed/v1/search?key=AIzaSyD500KZjSof98vSBhKTytpoP3rlJi69WXM=senior+assisted+care+near+me&zoom=9" width="600" height="450" frameborder="0" allowfullscreen="allowfullscreen"></iframe>

Should be:

<iframe style="border: 0;" src="https://www.google.com/maps/embed/v1/search?key=AIzaSyD500KZjSof98vSBhKTytpoP3rlJi69WXM&q=senior+assisted+care+near+me&zoom=9" width="600" height="450" frameborder="0" allowfullscreen="allowfullscreen"></iframe>

(added &q after the key, before the = sign)

working code snippet (you might want to restrict your key...):

<iframe style="border: 0;" src="https://www.google.com/maps/embed/v1/search?key=AIzaSyD500KZjSof98vSBhKTytpoP3rlJi69WXM&q=senior+assisted+care+near+me&zoom=9" width="600" height="450" frameborder="0" allowfullscreen="allowfullscreen"></iframe>

0
0

I just learned this and it totally worked for this exact case! Video here: https://www.youtube.com/watch?v=5klko9khrEs

Short answer

add gem dotenv-rails, after adding to Gemfile do a 'bundle'.

in .env -> write: GMAPS_API_KEY=foo4398439837

Now in seeds.rb -> write:

byebug

ENV["GMAPS_API_KEY"]

Now in terminal -> write: rails db:seed

if you type: ENV["GMAPS_API_KEY"]

it will show to encrypted value (Success!)

In your Google Maps link <%= ENV["GMAPS_API_KEY"] %> should work!

ex. src="https://www.google.com/maps/embed/v1/place?key=<%= ENV["GMAPS_API_KEY"] %>&q=NewYork"

I'm going a step further and using a database value for the address

ex. src="https://www.google.com/maps/embed/v1/place?key=<%= ENV["GMAPS_API_KEY"] %>&q=<%= @property.address.to_param %>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.