Tagged: 

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #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-key

    The 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/96dda43398bf6524e2d3d37ff7c75b89

    I 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 3 years, 11 months ago by  bitnissen.
    #661512

    Hi bitnissen!

    Thank you for posting your solution :)

    Best regards,
    Yigit

    #661569

    Same 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,
    Todd

    #662060

    Hey 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’);

    #662072

    Hey 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 3 years, 11 months ago by  bitnissen.
    #662197

    Hey you mean, your solution plus the code?

    #662199

    @tobiy

    Yes.

    #662262
    #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 3 years, 11 months ago by  Tobiy.
    #662400

    @tobiy please post the url of the site conteining the map.

    #662557

    done all above steps and still not working for us neither :/

    #662628

    Thanks for this! It worked on my website :)

    Cheers!

    #662771

    @gbdesignstudio please post the url of the site containing the map.

Viewing 13 posts - 1 through 13 (of 13 total)

The topic ‘Solution to Google Maps key-issues’ is closed to new replies.