google_api_key problem
Added by Josh Knox over 8 years ago
Hi,
Using Wt 3.3.5.
I've got a WGoogleMap in my app/server. It works fine when I run my app on my local machine. Also still works fine on a couple test boxes that have been running for a while (months)
I recently installed it on a remote machine. In a browser, the map no longer is displayed. Instead it shows an error message:
"Oops! Something went wrong.
This page didn't load Google Maps correctly. See the JavaScript console for technical details."
The browser console showed the following error:
Google Maps API error: MissingKeyMapError js?v=3&sensor=false&callback=google.loader.callbacks.maps:37 Google Maps API error: MissingKeyMapError.
Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys
So, I (re)generated a standard Google Map API key using the Google Developer Console. I put that key into the google_api_key property in my wt_config.xml, as:
<property name="google_api_key">AIzaSy6yPiPh123rEXAMPLEhCD6JvGrpY61TI</property>
However, I'm still getting this error in clients trying to load the map. My other test boxes, with same software build, load the map just fine.
I also noticed the key is not being passed when the google map API is loaded:
https://maps.googleapis.com/maps/api/js?v=3&sensor=false&callback=google.loader.callbacks.maps
Any suggestions on what I might be doing wrong?
Thanks!
Josh
Replies (3)
RE: google_api_key problem - Added by Josh Knox over 8 years ago
I modified WGoogleMap::render to add the google api key when the maps API is loaded.
strm << "setTimeout(function(){ delete " << initFunction << ";}, 0)};"
<< "google.load(\"maps\", \"" << (apiVersion_ == Version2 ? '2' : '3')
<< "\", {other_params:\"sensor=false&key=" << googlekey << "\", callback: "
<< initFunction << "});"
<< "}"; // private scope
That appears to get rid of the MissingKeyMapError.
Is this a bug?
RE: google_api_key problem - Added by Koen Deforche over 8 years ago
That must be a change on their side. I filed it as a bug #5298
RE: google_api_key problem - Added by Osman Zakir almost 8 years ago
I also need help on this. Where do I add the "property name='google_api_key'" tag? Do I add the path to the file itself in "application-settings location"? And if I want to enable JavaScript and AJAX and turn Progressive Bootstrap on, what changes do I make to the file (if any)?