I installed the gmap module thought I had everything configured properly but kept getting this error...

Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v2 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: http://code.google.com/apis/maps/documentation/javascript/v2/introductio...

I finally realized that I was using a 'Google Maps API Server Key' when I needed to be using a 'Google Maps API Browser Key'! Perhaps some of the Google Map API Key instructions could be updated on the gmap homepage and README file. How about this...

===
In order to use 7.x-1.x and earlier versions of this module, you need a (free) Google Maps API Browser key. Here is how to get one:

1. Login at https://code.google.com/apis/console
2. Create project
3. Go to 'Services' and turn on 'Google Maps API v2'
4. Go to 'API Access' and 'Create New Browser Key' specifying your domain url(s)
5. Paste the Google API Browser Key here ./admin/settings/gmap

Hope that helps someone.

Jeff

CommentFileSizeAuthor
#4 gmap-issue-1549272.diff813 bytesmicheas
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

carlodimartino’s picture

This is not working for me any more from today. The Google warning pops up after 5 seconds or so and the map disappears. I've generated new keys but same problem.

brandy.brown’s picture

@rectangle, make sure you have "Google Maps API v2" turned on under Services. If you have only v3 turned on, you will get errors.

carlodimartino’s picture

Status: Needs review » Active

Yes. I do have Google Maps API v2 turned on. I still get the error.
EDIT: http://drupal.org/node/818638#comment-5925902 solved my problem.

micheas’s picture

Status: Active » Needs review
FileSize
813 bytes

Instructions rolled into diff.

Should apply cleanly.

deepakjoshi’s picture

Status: Active » Needs review

Google API Console >> All Services

Make sure you have Google Maps API v2 marked as on under Services.

If only v3 turned on then it will give Javascript popup error.


Google API Console >>API Access

Now 'Create New Browser Key' for your url (localhost or domain)

sitename.com
sitename.com/*

Use Google API Browser Key in drupal module at ./admin/settings/gmap

micheas’s picture

deepakjoshi: Are you commenting on my patch?

I really don't understand you post at all.

webservant316’s picture

I've seen others say that you need to include both 'yourdomain.com' and 'yourdomain.com/*' for the domain key to work. Maybe that is what he is saying. However, that is not my experience, nor is that what the google docs say here https://developers.google.com/console/help/#restrictingusage. Seems to me that my initial proposal to revise the docs still stands as simple and concise, plus there are links to the google docs right in their api console.

It may be that some installations need 'yourdomain.com/*' because of DNS or .htaccess complications. Dunno, but I don't need it for my install to work.

micheas’s picture

webservant316:

I agree with you that the issues of *.example.com/*, *.example.com are laid out in the Google.com control panel.

Not having them here seems to me to make maintaining the documentation easier, as when google makes a change to the requirements we don't have to go through the patching process to update the documentation.

webservant316’s picture

yep

micheas’s picture

Status: Needs review » Patch (to be ported)
betovarg’s picture

I can confirm the instructions from OP worked. My site is now showing maps correctly.
Thanx!

klucid’s picture

I had this issue just moments ago. For whatever reason, I had to turn off the v3 service as well. It seems that having both services on was causing an issue.

brandy.brown’s picture

OK. I think I finally solved my problem with this by Creating a new project (I was trying to use an old project while just generating a new key) and then allowing all referrers. We'll see...

fonant’s picture

Creating a new "Project" in the Google APIs Console was needed for me too.

japo32’s picture

HI, this is what worked for me. It's the same as the first post, almost:

1. Login at https://code.google.com/apis/console
2. Create project
3. Go to 'Services' and turn on 'Google Maps API v2'
4. Go to 'API Access' and copied the API key under "Key for browser apps (with referers)"
5. Paste the Google API Browser Key here ./admin/settings/gmap

thanks

youssefr’s picture

This works...

http://www.websitename.com/
http://websitename.com/
www.websitename.com
websitename.com
www.websitename.com/*
websitename.com/*
*.websitename.com/*
Summit’s picture

Hi,

For me the only thing what helped is to set the referrer to: "Any referer allowed".
With any other combination I got:

Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v2 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: http://code.google.com/apis/maps/documentation/javascript/v2/introduction.html#Obtaining_Key

Greetings, Martijn

Sarai Leon’s picture

5. Paste the Google API Browser Key here ./admin/settings/gmap

Hey I'm just missing that step, I can't find that in the google api console. Can you tell me where it is?

karolus’s picture

Version: 6.x-1.x-dev » 7.x-2.3-alpha2

deepakjoshi does have a point...

I'm using 7.x, but the underlying issue shouldn't be any different from the 6.x versions of this module.

Recently, I had to migrate a Drupal site to a new Web host, and although there were no changes to the site itself, besides its location, I would be getting the Google Map API key issues related to above this post.

First thought it may have to do with the SSL, but disabled forcing redirects to it, and ruled that out...

I generated a new key, careful to make sure v.2 was selected, but still the same issues. Putting the URL in the key in a variety of different formats (e.g. sitename.com
sitename.com/*) did the trick.

whatsonmap’s picture

Try adding
&sensor=false
to the end of the script src= line as so:
script src="http://maps.google.com/maps?file=api&v=2&key=YOURKEY&sensor=false"

Sandip Choudhury’s picture

Thanks Jeff, your instruction to update about google api key (https://code.google.com/apis/console) is working fine for me.
But please update this api link in the module also.

Again thanks for this good work.

podarok’s picture

Title: Please update your google api key instructions » Latest google api key instructions
Version: 7.x-2.3-alpha2 » 7.x-2.x-dev
Assigned: Unassigned » podarok
Status: Patch (to be ported) » Fixed

Thanks!

updated README.txt for 7.x-2.x and 7.x-1.x branches with this instruction
will be tagged in next minor release update

Sandip Choudhury’s picture

Status: Closed (fixed) » Fixed

Drupal Community is so helpful !! I wish that someday I will also help in Drupal community. Currently learning Drupal and PHP.

Bravo ! Bravo ! Drupal Community.

podarok’s picture

Status: Fixed » Closed (fixed)

updated project
http://drupal.org/project/gmap
page also

miccelito’s picture

Status: Fixed » Active

Sorry to re-open the issue..

Mentioned at project page...
1. Login at https://code.google.com/apis/console
2. Create project
3. Go to 'Services' and turn on 'Google Maps API v2'
4. Go to 'API Access' and 'Create New Browser Key' specifying your domain url(s)
5. Paste the Google API Browser Key here /admin/settings/gmap

All done but I get a promt message: "Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v3 on this site. If you are the owner of this application, you can learn about obtaining a valid key here..."

Don't know what could possible be wrong? (I'm using GMap 6.x-2.0 beta2)

Further, someone told that Google has sent out emails reminding that the formal deprecation period for v2 of the API ends in May, 2013, after which they suggest that v2 won't work at all.

If at Google console 'Services' turning on both 'Google Maps API v2' and 'Google Maps API v3' and at 'API Access' choosing "Referers: Any referer allowed" seems to solve it and no error promt showing.

Has anything changed recently?

Media Crumb’s picture

Same issue. No matter what I do I can't get this to work on D7. I've followed all the steps countless times

polmaresma’s picture

I'm on GMAP Location 7.x-2.7-rc1 and still receive the Key message.
I tryed every combination of V2/V3 and allowed sites possible without luck.
On other projects I have the same configuration working, is it possible that Google locks new Keys for V2?

Thank's for all.

calefilm’s picture

I'm giving up. Same as #27

twseid58’s picture

using API v3 only and including the list from #16 is what worked for me.

hot_sauce’s picture

Confirmed what twseid58 did - if you make sure your list of sites is accurate then the code should work in V3. I don't think that you can create new keys for V2 anymore. Also, its critical that you get the paths for your site correct. My hang up was on this one:
*.websitename.com/*
I kept the . in place after the first asterisk for some reason thinking this would work for sites without a www in front of them. Fixed that and everything worked fine.

TLDR: The instructions currently on the site work correctly, you just have to make sure you have the sites listed EXACTLY correct or Google will boot you.

quicksketch’s picture

Hi guys, I've included new instructions in the issue to rewrite the README.txt file at #1837224: Update README.txt for Drupal 7.x-2.x branch. Getting that issue fixed would also solve this problem.

2¢’s picture

@twseid58 mentioned this in #29, but I feel it should be stated more boldly as it was part of my problem.

You cannot have both V2 & V3 on, only enable V3.

[adding 2¢] I had to use *mysite.com/* because I'm using .htaccess to rewrite to a drupal install in a subfolder (I like keeping my web root tidy).

B Leg’s picture

No matter what I still can't get this working. I keep getting that popup with the unsolvable message.

I've created and re-created the API key dozens of times for both API versions, I've tried the referrer list and a bunch of others I made up, I've re-generated the key in the API Access panel, I've flushed my caches, I'm only using one API version at a time. It just doesn't work. What are some next steps for me to take here because I need this map to show up.

daschwan’s picture

I got it to work!!!!!!

Created a NEW project in Googele apis

1. Login at https://code.google.com/apis/console
2. Create a NEW project (The key word is NEW. when i used an old project it did not work!)
3. Go to 'Services' and turn on 'Google Maps API v3'
4. Go to 'API Access' and 'Create New Browser Key' specifying your domain url(s) (I used *mysite.com/* )
5. Paste the Google API Browser Key ( www.yoursite.com/admin/config/services/gmap )

And now it works just fine :)

daschwan’s picture

Issue summary: View changes

fix blockquote tag

kopeboy’s picture

Issue summary: View changes

I can't get it to work on a Pantheon sandbox site (http://dev-mysite.gotpantheon.com/), using 7.x-2.9.

Can anybody help on how I should insert it in the referrals?

I tried with this but it's not working:

http://www.dev-mysite.gotpantheon.com/
http://dev-mysite.gotpantheon.com/
www.dev-mysite.gotpantheon.com
dev-mysite.gotpantheon.com
www.dev-mysite.gotpantheon.com/*
dev-mysite.gotpantheon.com.com/*
*.dev-mysite.gotpantheon.com/*

Also, the only available Service with "V3" is called "Google Maps JavaScript API v3", not Google Maps API V3, is it right?

Should I use the dev version or (like the module page says) am I ok with 2.9 to work with Google Maps API v3?

kopeboy’s picture

OK, I ruled out the V3 option, that isnt the problem.

I also tried with a domain I actually own, and I couldn't get it to work. A new message a was getting was

"Google has disabled use of the Maps API for this application. See the Terms of Service for more information: http://www.google.com/intl/en_US/help/terms_maps.html." but maybe that was caused by me changing the API keys too much too fast.

Finally I got everything working with these referrals rule (working for a normal domain without subdomains too, ie: without "gotpantheon"):

https://mysite.gotpantheon.com
https://mysite.gotpantheon.com/
https://mysite.gotpantheon.com/*
*.mysite.gotpantheon.com/*
*mysite.gotpantheon.com/*
http://mysite.gotpantheon.com
http://mysite.gotpantheon.com/
http://mysite.gotpantheon.com/*

and enabling the service "Google Maps JavaScript API v3" only.

kopeboy’s picture

Version: 7.x-2.x-dev » 7.x-2.9
Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: gmap-issue-1549272.diff, failed testing.

Vako’s picture

Google has changed their page and the instructions are not working as described. I can't even find what needs to be acquired, can someone help please.

crutch’s picture

The key seems to be required again. Localhost has stopped showing maps.

---

http://stackoverflow.com/questions/19784661/google-maps-v3-api-for-local...

"(As Jeff Hoye pointed out, as of June 22, 2016, an API Key is required again.)

And then you forgot the "new" in this line:

var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);

With those changes your map will be displayed."

daggar’s picture

The top three threads in the issue list are all related to the out-of-date Google API documentation. As I recommend on this other thread, the module might profit from an official, perpetually-open and hopefully-updated thread that tracks Google's API changes. The dev isn't to blame that Google rearranges vital controls, but it's frustrating for new users trying to do a new setup.

schnoodle’s picture

Yet again, this is incredibly outdated.

Currently, to get mine to work - As of 6/27/2017:

  1. Go to https://console.developers.google.com/apis
  2. If you don't already have a project, make one.
  3. Under Library > Choose Google Maps Javascript API
  4. Grab the API Key( Credentials > API Key ), insert into Google Maps API Key ( in /admin/config/services/gmap )

Voila. Should be working.

Pascal-’s picture

For those wondering, at the current date the following API key is working for me:
Google Maps JavaScript API

It's also working without an API key though.

buntstiftmuffin’s picture

Well, I am confused. Got a client page on our server (without any API key!), gmaps work perfectly. Migrated to the client server, gmap is missing the api key.
I made a new project with a new key, but I don't know where to put it to.
I don't have this
www.yoursite.com/admin/config/services/gmap

I have drupal 8 and no gmap module installed...I placed the API code in the 'tracking code' field of the template (okno) - well doesn't work. Someone any idea?

System Lord’s picture

Finally! Same as #43! Glad that nightmare is over! Now, off to Best Buy for a new keyboard. Lowes for drywall patch. Treats and apologies for my dog!

What's odd is the warning I'm still getting in inspector console:

util.js:228 Google Maps API warning: SensorNotRequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required

I wonder if it's module that kicks off that warning? It can't be coming from Google, right?

Pascal, you said it also works without the API key. I don't understand how that's possible. If Gmap isn't communicating with google api's then what difference does it make what service you/we enable? How does our site know what service we selected? Weird

picxelplay’s picture

#43 worked for me as well. All of a sudden maps stopped working (in and out of the GMap module). Tried regenerating keys, nothing. Tried recreated the project, nothing. Enabling "Maps JavaScript API" fixed it.

John_B’s picture

Google now require us to enable billing before creating a new 'Service'. Until you have enabled billing it is not possible to enable the Maps JS API.

espurnes’s picture

As John_B says, you must enable billing (by adding a credit card) to use the google maps service. But it seems google give you 200$ credit to use the service. So for small sites with few queries to google services it seems it is still free.

I've not tested yet.

For each billing account, a monthly $200 USD Google Maps Platform credit is available and automatically applied to the qualifying SKUs.

https://cloud.google.com/maps-platform/pricing/sheet/

espurnes’s picture

I updated a patch on https://www.drupal.org/project/gmap/issues/2818471 that adds the API KEY in te gmap_geocode function.
To use the geocoding you must set an api key and use https in your site.

Vali Hutchison’s picture

I have GMAP 7.x-2.11 running on a site and Google Maps stopped working due to the API issue. I tried creating a 'free' API the old way but this gave a JS error. So then went for the billing account via https://cloud.google.com/maps-platform/#get-started and generated an API that way and now maps are working again on the site. Didn't need to patch the GMAP module.

John_B’s picture

Didn't need to patch the GMAP module.

It needs one of us to make a patch because the help text is misleading, and updated help text will save others time.

triad_interactive’s picture

I'm using Gmap 7.x-2.11 and have entered a new valid (and tested) API key that is attached to a new Google billing account. But my map view is still showing the "For development purposes only" overlay. I've reached out to Google support, and they said that the module is not referencing the key properly. Are there additional steps I have to take to get this working correctly?

crutch’s picture

There shouldn't be anything to do on the module side. It is more than likely the google account side of things (not very easy). I think they sent a different key once setting up or confirmed, I can't recall exact details at this point. It may take a few hours or longer for it to activate once setting up billing account. That is the only issue we experienced.

jonahruh’s picture

triad_interactive, Did you figure out how to get it working? I also set up a google billing account, got and restricted an API Key and still keep getting the 'for development purposes' error. I installed the Chrome extension that checks your keys and it says ERROR: You seem to be using a malformed key. I am simply pasting the key they gave me into the GMap module field for the key. Im not sure what else to try. Anyone have this issue and resolved it?
Thanks!

gayathri09’s picture

I'm also having same issue. I configured billing account API key, still it's showing "for development purposes". any patch is available for module?
Thanks

Vali Hutchison’s picture

triad_interactive and gayathri09 have you associated a credit card with your google API account? This is required I thinkeven if you don't then get charged so maybe this is the issue? See here for example:

https://stackoverflow.com/a/50977984/4193509

miguel.delcampo’s picture

One week ago, I had to do requests to Google Maps API whithout APIKEY in my site web. Now I obtain the next code error: REQUEST_DENIED

Why I could to do correctly resquests one week ago? I see that the new Google policy is from 16th July.

Thanks.

danzVP06’s picture

I'm also having the same issue, credit card is also connected to my billing account. Created Maps JavaScript API with no restriction and with referrers. The map is still not yet working. I just copied my API credentials and pasted in on the configuration side but I'm still getting an error. On the configuration side I'm getting this error:

Oops! Something went wrong.
This page didn't load Google Maps correctly. See the JavaScript console for technical details.

On the display page, I'm getting "For development purposes only"

When using the Google Maps Platform API Checker, I get this error:

Maps Platform Report
ERROR: This site doesn't seem to be using an API key. Keyless usage will soon be deprecated. Please set up and secure a key for your project.

jonahruh’s picture

Wow, I finally got this working. Thanks Vali for the stackoverflow link. I enabled the Api's i needed for my project. It still didn't work and so i clicked on google support. It said i needed to fix a problem with my billing account. I clicked on the link provided and had to assign the project to my billing account. Now it is working!
I just created a second project for another site and it went up like a breeze. Assigning the Api's you need is the key.
Here are the directions again if you have set up an account and your map is still not working:

Go to this link: https://console.developers.google.com/apis/dashboard.
Then you select your project in the dropdown.
Go to library on the left pane.
Browse the available APIs and enable the one you need.

Also be sure to restrict your key.

rblackmore’s picture

I'm trying to get a Google Maps Javascript API key working with Gmap 7.x-2.11 and so far I've had no success.

This is what I've done:

  • Create a key with a billable account
  • For now the key is unrestricted
  • Add the key to "Google Maps API Key" under admin/config/services/gmap
  • Confirmed the key works with another non-Drupal map application

Result:
My maps display this error "Oops! Something went wrong. This page didn't load Google Maps correctly. See the JavaScript console for technical details."

Console log errors on map pages:

  • Google Maps JavaScript API error: InvalidClientIdMapError
  • Google Maps JavaScript API warning: ClientIdLooksLikeKey

The gmap admin form doesn't have a ClientId field. Am I mis-reading the instructions or have I encountered a different problem, requiring the creation of a new issue?

rblackmore’s picture

OK. After a load of troubleshooting, including running several drush up commands and update.php, this fixed my problem: Without uninstalling I deleted gmap and ran "drush dl gmap". That fixed everything. No idea why.

gisle’s picture

This issue is from 2012, and there is a lot of outdated stuff in the thread. I think it should be closed and a new one opened in its place. The API instructions that comes with the module is outdated. For instance, an API key is now required.

For what it is worth, here are the steps I had to comply with to get an embedded map working by means of this project:

1. Set up a project in the Google APIs console.

2. Generate an API key for the project.

3. Enable the following two APIs:
- Maps Embed API
- Maps JavaScript API

4. Add billing to the project (even if you will not permit Google to charge you).

amcc’s picture

#50 worked for me (in August 2019 i.e. just now)

liquidcms’s picture

all my sites with gmap stopped working today. i had to go in and enable billing as per #50 above (even though it came back with the same api key i already had).

GMap Module 7.x-2.11+3-dev (2017-May-22) and a cache clear and maps started working again.

apaderno’s picture

Version: 7.x-2.9 » 7.x-2.x-dev
Assigned: podarok » Unassigned
earthangelconsulting’s picture

hello maintainers!

i am not sure if the D8 version of gmap is now dead in the water, or what, but either way.. i am assuming you must have some idea of what the current Google API instructions are, for this module, since you were porting it, as of two years ago?

is there any chance you could please please please post those here, and/or add them to a new recommended release of gmap, even if that's the only difference from the last one? ;-)

some of us will be maintaining D7 sites for another year or two at least, and having this module usable (even if you don't make any more changes to it) would be great... and trying to understand Google's documentation, or all the different API key types (look at this list! https://developers.google.com/maps/faq?csw=1#using-google-maps-apis) would REALLY help!

thanks!

crutch’s picture

There shouldn't be an issue with the module. We are running the current gmap on multiple sites. You will need to work on Google API https://console.cloud.google.com/apis/credentials and select the correct project to confirm the correct keys are active, etc. It may take a few minutes for it to update and start working or if you are new to payments then it may take a few hours (they said that to us on the phone when setting up payments #53 and it did take that long).

earthangelconsulting’s picture

thanks @crutch !

as you said, the problem isn't with the module, it's just with the instructions that come with it. and i realize that it isn't necessarily the gmap maintainer's job to stay on top of every single change that google makes to their API instructions, which seem to change all the time... as long as the module's requirements as to which type of API key are not changing.

that's the part that i am having the problem with... out of all these key types shown on page https://developers.google.com/maps/faq?csw=1#using-google-maps-apis, which of these is relevant? does it depend on exactly what you are using the gmap module for?

crutch’s picture

Ah I see, use Maps JavaScript API, https://developers.google.com/maps/documentation/javascript/overview but it's not needed to understand the whole of that page because the module does it for us.

We just need the js api key https://developers.google.com/maps/documentation/javascript/get-api-key

But first we must have a Google Cloud project in our Google Cloud Console https://developers.google.com/maps/documentation/javascript/cloud-setup then we can create and restrict the key to our website(s).

We can use a single Google account and key for multiple sites. Or maybe for a specific customer, the key could be set up under their Google account and they would be responsible for the bill (if they surpass the allowed monthly credited/free requests).

Once finished with the Google items, then add key to the module at /admin/config/services/gmap.

earthangelconsulting’s picture

@crutch - thanks, that's very helpful! i will try that :-)