Tagged: API, api key, google maps, javascript error
-
AuthorPosts
-
September 4, 2018 at 5:23 am #1005260
Hello, I am working on an issue involving the new Google Maps API (yes I know, you guys must hate it by now…)
One of our client sites (link in private data) has a map that is returning a Javascript error.“Oops! Something went wrong.
This page didn’t load Google Maps correctly. See the JavaScript console for technical details.”According to the Console, this would be caused by an invalid key. I have however created several new keys following instructions, enabled billing on the account and ensured the credit card works (it works for other sites in our organization).
I contacted Google about this and they have pointed out that the key in the source code for the page shows that there are spaces (“%20” when URl encoded) in our “key” parameter. (see private data)
When I check the Google services page on the API settings, there is NO space before or after the key. I have tried disabling server side static caching, deleting the key, saving settings then re-pasting making sure there is no space, etc. but the space persists.
Any ideas?
Thanks,
September 4, 2018 at 10:42 am #1005381Hey Commun-IT,
To be honest I doubt this code is from our theme. Please deactivte your wordpress plugins (and your custom code) to see if Enfold outputs the invalid code. Enfold normally adds following code to the website to load the maps (I can also see this code on your webswite in the footer area):
<script id='avia_gmaps_framework_globals' type='text/javascript'> /* <![CDATA[ */ var avia_framework_globals = avia_framework_globals || {}; avia_framework_globals.gmap_api = '[YOURAPIKEY (with no spaces)]'; avia_framework_globals.gmap_maps_loaded = 'https://maps.googleapis.com/maps/api/js?v=3.30&key=[YOURAPIKEY (with no spaces)]&callback=aviaOnGoogleMapsLoaded'; avia_framework_globals.gmap_builder_maps_loaded = 'https://maps.googleapis.com/maps/api/js?v=3.30&key=[YOURAPIKEY (with no spaces)]&callback=av_builder_maps_loaded'; avia_framework_globals.gmap_backend_maps_loaded = 'https://maps.googleapis.com/maps/api/js?v=3.30&callback=av_backend_maps_loaded'; avia_framework_globals.gmap_source = 'https://maps.googleapis.com/maps/api/js?v=3.30&key=[YOURAPIKEY (with no spaces)]'; avia_framework_globals.gmap_avia_api = 'http://qcgn.ca/wp-content/themes/enfold/framework/js/conditional_load/avia_google_maps_api.js'; /* ]]> */ </script>
Best regards,
DudeSeptember 4, 2018 at 8:20 pm #1005743Thank you Dude!
I didn’t think about that possibility – I thought it was a bit of theme code.
It turned out it was an API key transferred improperly (and automatically) by our Geodirectory plugin was the culprit.
Thank you. Case solved!September 5, 2018 at 3:07 am #1005844 -
AuthorPosts
- You must be logged in to reply to this topic.