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

geocodezip
  • 158,664
  • 13
  • 220
  • 245
Shannon
  • 21
  • 1
  • 1
  • 2
  • what wrong with this answer.. https://stackoverflow.com/questions/49189543/google-maps-embed-failed-invalid-request-missing-the-q-parameter – bcperth Nov 23 '18 at 22:40
  • did you have a look at https://stackoverflow.com/questions/22939725/why-has-google-maps-q-parameter-stopped-working ? Please note that it is stated here (https://productforums.google.com/forum/#!topic/maps/l56Ms3bfOj8) that Google's support for Maps is migrated here. – LoneWanderer Nov 23 '18 at 22:46
  • Possible duplicate of [Google Maps JS API v3 - Simple Multiple Marker Example](https://stackoverflow.com/questions/3059044/google-maps-js-api-v3-simple-multiple-marker-example) – Bennett Dams Nov 23 '18 at 22:54
  • Possible duplicate of [Why has google maps "q" parameter stopped working?](https://stackoverflow.com/questions/22939725/why-has-google-maps-q-parameter-stopped-working) – Kind Stranger Nov 23 '18 at 23:47

2 Answers2

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>
geocodezip
  • 158,664
  • 13
  • 220
  • 245
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 %>

Dharman
  • 30,962
  • 25
  • 85
  • 135