Tagged: google maps
-
AuthorPosts
-
July 15, 2016 at 8:15 pm #661496
Dear all,
Can’t get the Google Maps-widget and “Fetch Coordinates” in the admin, to work? Look no further!
I have been banging my head against the wall like the rest of you because of the Google Maps browser-key issues. So I decided to take things into my own hands and have created a patch.
All you’ve gotta do, is copy-paste the following snippet into your functions.php AND change the GOOGLE_MAPS_KEY with your own key. API-keys are free. To get the required key, follow Google’s own instructions, which can be found here:
https://developers.google.com/maps/documentation/javascript/get-api-keyThe code makes the following work again:
- Front-end maps
- Back end geo-coder (= when looking up an address)
It ain’t perfect, like the javascript will now throw a couple of exceptions, but it’ll get the job done and only developers with the developer console open, would notice these errors anyway.
Grab the code here:
https://gist.github.com/mortenskyt/96dda43398bf6524e2d3d37ff7c75b89I hope it worked for you! I don’t really intend to do any support on this, but if you find a flaw, then of course I’m curious ;-)
- This topic was modified 8 years, 3 months ago by bitnissen.
July 15, 2016 at 8:54 pm #661512July 16, 2016 at 1:43 am #661569Same problem here with no maps because of API key. This solution works for a temp fix. Just verified. Don’t forget to remove the first line on the GitHub snippet. Add the GitHub snippet to your functions.php file then add the API key from Google to the const GOOGLE_MAPS_KEY in the top of the snippet.
Thanks @bitnissen for the temp solution!!!
Best regards,
ToddJuly 18, 2016 at 3:34 pm #662060Hey there does not work
put this code into the functions.php.
But it does not load: console says: Google Maps API error: RefererNotAllowedMapError
I put the url and the contact page as referer site….function ava_googlemaps_apikey() {
$prefix = is_ssl() ? “https” : “http”;
wp_deregister_script(‘avia-google-maps-api’);
wp_register_script( ‘avia-google-maps-api’, $prefix.’://maps.google.com/maps/api/js?key=API-CODE‘, array(‘jquery’), ‘3’, true);
wp_enqueue_script(‘avia-google-maps-api’);
}Can you please give a hint? Thank you very much!
add_action(‘init’, ‘ava_googlemaps_apikey’);July 18, 2016 at 3:42 pm #662072Hey Tobiy,
If my solution didn’t work, then try add this as well to the functions.php:
if (!is_admin()) { add_filter('avia_google_maps_widget_load_api', '__return_false', 999); }
It seems that in some cases, the enqueing of the google maps without the proper key, still occurs. The above has fixed it for me in the instance where I experienced it as well.
- This reply was modified 8 years, 3 months ago by bitnissen.
July 18, 2016 at 6:53 pm #662197Hey you mean, your solution plus the code?
July 18, 2016 at 6:56 pm #662199@tobiy
Yes.
July 18, 2016 at 8:44 pm #662262@tobiy you can use my solution: https://kriesi.at/support/topic/google-maps-7/#post-656457
July 19, 2016 at 10:02 am #662378@bitnissen Thank you very much! Your solution makes the console happy – no errors anymore. But unfortunately the card is not loading. Even if i put the coordinates manually i am landing in the ocean, where i am definitely not located :-)
@mensmaximus Thank you very much ! but my src looks quite different: src: ‘https://maps.googleapis.com/maps/api/js?v=3.6&sensor=false&callback=aviaOnGoogleMapsLoaded’ It does not work either. Cleared all caches (plugins and browser (hard reset), tried it with different mobile devices. WAIT: Its loading, but it does not get my coordinates even if i put them manually…..again a citizen of somalia…Guys thank you.Its quite frustrating.
- This reply was modified 8 years, 3 months ago by Tobiy.
July 19, 2016 at 11:09 am #662400@tobiy please post the url of the site conteining the map.
July 19, 2016 at 3:32 pm #662557done all above steps and still not working for us neither :/
July 19, 2016 at 4:51 pm #662628Thanks for this! It worked on my website :)
Cheers!
July 20, 2016 at 5:27 am #662771@gbdesignstudio please post the url of the site containing the map.
-
AuthorPosts
- The topic ‘Solution to Google Maps key-issues’ is closed to new replies.