Tip: Adding Google Map API Key properly to enable GMap Views in Drupal

Yesterday during Lab Hours we went through the process of adding and configuring a GMap view in a Drupal site. We've done this before but ran into a few hurdles that we'd forgotten about. Here is the first of several tips to keep you from suffering as much as we did.

Our frustration is rooted in the fact that the settings for a successful GMap implementation are spread far and wide in Drupal. Once you think you've handled everything, another hidden setting must be found and dealt with. You must complete settings for three separate modules: GMap, GMap Location (which comes packaged with GMap module) and Location (a separate module).

Here's our Tip: You need to add your Google Maps API key in TWO places in your settings. One is logical, the other confusingly hidden away (in our humble opinion).

First, the key (which you must obtain directly from Google before you get to this step) must be entered into the GMap module's settings. Once the module is enabled, go to Administration>Site Configuration>GMap and enter your Google map API key into the designated field.

Second, the key must also be entered into the Location module's settings. Once you have the Location module enabled, go to Administration>Site Configuration>Location and click on the Geocoding Options tab. Enable the Google Maps geocoding feature by clicking on the radio button. And you'd think you're done, right? Wrong! Before clicking on Save Configuration, look to the right under the Configure column and click on the "Configure parameters" link. I know, I know, it looks like it's next to the Yahoo Maps feature, but click it anyway. THIS is where you need to enter your Google Map API key so that the Location module will use Google Maps to geocode (essentially add latitute and longitude settings) to the location information in your nodes. Otherwise? No pins on your GMaps.

That's our tip. Note that this is not everything you need to do to get a GMap view up and running, but it is the step that's tripped us up twice now.
Your rating: None Average: 3.5 (16 votes)

Comments

Where is the API Key stored?

I migrate my site from a development machine to a staging site. This involves doing a mysqldump of the local database and importing it into the staging DB. This works great expect that it overwrites the Google Maps API key for the staging site - registered to "MyDomain.com, with the one from my development machine - registered to "localhost". Consequently, I get "The Google Maps API key used on this web site was registered for a different web site..." error after every migration. I would like to add a special case to the migration scripts to fix this. Anyone know where the API Key is stored?

Thanks
Jason

Location module now gets the key from Gmap module

I followed your instructions, but when I got to the Configure parameters part, the Location config page told me:

Google Maps API Key:
XXXXXXX---my key--XXXXXXX
The key in use was automatically provided by GMap.

So things seem to have gotten alittle simpler since you wrote this (which is good!)

Which key?

This may seem like a silly question, but when I go to the google page, there are many choices for which type of key I need .. I don't know which to choose ..??

Thanks in advance

thanks

thanks

you were wrong

You have to change the value of the Api key in the gmap.module to make the google map work on your drupal website.

Post new comment

  • Allowed HTML tags: <a> <img><b><i> <em> <h1> <h2> <h3><h4><h5><h6> <sub> <super> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <p><sup>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options