Google Maps API issue

This topic contains 13 replies, has 3 voices, and was last updated by  Stiofan O’Connor 4 years, 11 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #487947

    Edward Solomon
    Full Member
    Post count: 18

    Hi, I’m hoping someone can help us clear up this issue.

    We have the following plugins installed that use Google maps:

    GeoDirectory Version 2.0.0.59
    The Events Calendar Version 4.9.2

    However, when the API key for GD maps is set, on some browsers, the maps on The Events Calendar pages don’t display correctly. On inspecting the console for those occurrences, an error message says the Maps API is being called more than once on that page, which can cause errors. On further inspection it seems the GD Google maps API call is being made globally, for every page of the site, and so for Events Calendar pages the API call was doubling up.

    So we installed the following plugin in order to fix the issue:

    API Key for Google Maps Version 1.2.0

    and according to the instructions, removed the Google Maps API key from the GD settings, and added it to the Google API Key settings page (Retro Add Google Maps API KEY).

    This fixed the issue on the Events Calendar pages, however on the GD pages the fallback maps from OpenStreetMap are being displayed, and not Google Maps, meaning the ‘API Key for Google Maps’ plugin either doesn’t work properly or some setting in GD needs adjusting.

    Would appreciate some guidance in fixing this issue.

    Many thanks.

    #487969

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    you should be able to remove the API key from the other plugins and GD will make it available for all of them. Give that a try and if it doesn’t work please make a private reply with site credentials so we can take a look.

    WordPress Administrator Account Credentials
    WP Admin Login URL:
    Username:
    Password:

    SFTP / FTP Credentials
    Host URL:
    Port:
    Username:
    Password: “

    #487973

    Edward Solomon
    Full Member
    Post count: 18
    This reply has been marked as private.
    #488005

    Alex Rollin
    Moderator
    Post count: 27815
    This reply has been marked as private.
    #488006

    Edward Solomon
    Full Member
    Post count: 18

    Have changed the slug for The Events Calendar, but GD is still using Open Streetmaps instead of Google Maps.

    #488012

    Alex Rollin
    Moderator
    Post count: 27815
    This reply has been marked as private.
    #488013

    Edward Solomon
    Full Member
    Post count: 18

    I’ve done that. The problem is that now GD has the Maps API key set, the Events are broken because there is an error in the console, which shows the page is calling the Maps API multiple times. This doesn’t happen when the key is not set in GD. If you view the page of any event, look at the console and you will see the resulting error. The problem manifests itself particularly on Microsoft Edge and Apple Safari, which renders many Windows and Mac users prone to this problem.

    #488016

    Alex Rollin
    Moderator
    Post count: 27815

    Remove the key from the Events addon.

    If that doesn’t work, then share FTP and we will debug the issue.

    Setup needed:

    Set GD to use Google maps, with API key set in GD
    Events – change events slug, remove API key.

    #488025

    Edward Solomon
    Full Member
    Post count: 18

    1. GD set to use Google Maps (to the best of my knowledge) and API key set in GD.
    2. Events slug changed to ‘our-events’. API key *cannot* be removed. The API key is mandatory. If the custom API key is removed, an autogenerated key appears and is used by The Events Calendar. The problem with the Google Maps API doesn’t go away.

    Surely the standalone GD Maps plugin we installed should push the API key to anything that requires it?

    Note that now there is no map appearing for GD either.

    #488116

    Alex Rollin
    Moderator
    Post count: 27815
    This reply has been marked as private.
    #488329

    Edward Solomon
    Full Member
    Post count: 18
    This reply has been marked as private.
    #488630

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hello,

    The events cal and GD are loading the Google API, we add some extra stuff they don’t which would mean its better to remove their call, i have tried the standard way but it does not seem to be working:

    function _my_events_cal_dequeue_script() {
       wp_dequeue_script( 'tribe-events-google-maps' );
    }
    add_action( 'wp_print_scripts', '_my_events_cal_dequeue_script', 100 );

    If you can please ask them how to remove their API call that will solve it.

    Thanks,

    Stiofan

    #489725

    Edward Solomon
    Full Member
    Post count: 18

    Hi Stiofan,

    We’ve made the decision to localize the GD maps API call to just the GD pages using it so that this conflict doesn’t perpetuate itself across the rest of the site. It’s unreasonable to amend the functionality of other plugins when it is GD making a global call.

    Kindly provide a function or code snippet (or point to it in the documentation) we can use to
    1. globally dequeue the GD maps API call
    2. enqueue the GD maps API call for just the GD pages (we’ll target the pages by ID).

    Many thanks.

    #489741

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Our script key is “geodir-google-maps”

    Not tested but try something like this:

    function _my_gd_dequeue_script() {
       wp_dequeue_script( 'tribe-events-google-maps' );
    }
    add_action( 'wp_print_scripts', '_my_gd_dequeue_script', 100 );

    We use the api for more than just maps, its also used for things like location autocomplete, and to set the user location if normal browser location fails.

    The other way makes much more sense to me but its your call how you want to implement it.

    Thanks,

    Stiofan

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket