Google Maps API errors with TEC Pro 4.4.30

Home Forums Calendar Products Events Calendar PRO Google Maps API errors with TEC Pro 4.4.30

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1591519
    Lou
    Participant

    With the upgrade to The Events Calendar Pro 4.4.30, some theme-custom code which draws on google maps overlays stopped working.

    With TECPro 4.4.30 running now seeing the error

    You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors.

    which I think leads to

    InvalidValueError: setMap: not an instance of Map; and not an instance of StreetViewPanorama

    downgrading to TECPro 4.4.29.2 alleviates this problem.

    I have TECPro 4.4.29.2 running at https://steeplechasers.org/ and 4.4.30 running at https://sandbox.steeplechasers.org/

    The error can be seen at https://sandbox.steeplechasers.org/training/running-routes/ . The expected behavior is at https://steeplechasers.org/training/running-routes/

    I tried removing my statement
    <script src=”//maps.google.com/maps/api/js”></script>

    but then google.maps is undefined.

    I suspect this has something to do with the new tribe_assets, but of course not sure.

    What do you recommend?

    ( I see someone else is having trouble with the google maps API but they marked their post as private )

    #1592445
    Cliff
    Member

    Hi, Lou. Thanks for your detailed message.

    FYI: Protocol-relative script like //maps.google.com/maps/api/js isn’t the best way. Always load it HTTPS.

    I visited your site and saw a console errorhttps://cl.ly/3r2E0e1a3s3T
    (If needed, you may reference our KB article Using Google Chrome Developer Tools.) You should get that resolved, but it’s separate from our plugin.

    Additionally, your favicon is a 403: https://cl.ly/0m0h2f32092i

    Regarding our plugin…

    I see you have Google Maps loaded multiple times and there’s also a No API Key warning.

    Are you wanting to have our Google Maps script not load at all? If yes, maybe you had a custom code snippet in place that needs to be updated for the new way to load assets?

    #1592461
    Lou
    Participant

    Thanks for the pointers to the other errors.

    Yes for this page only is there a way to either disable The Events Calendar Pro or to disable its use of google maps?

    I’m not sure I understand the question, “If yes, maybe you had a custom code snippet in place that needs to be updated for the new way to load assets?” Are you talking about loading the google map? I am loading that directly as you saw. What do you recommend instead?

    Also, please recall this is a new problem with 4.4.30, if that helps.

    #1592488
    Cliff
    Member

    Since it’s a new issue, I thought maybe you had custom code to dequeue our script and maybe that custom code didn’t work for the latest versions… just a thought why it might have worked before but not now.

    Please view the snippet at https://theeventscalendar.com/knowledgebase/troubleshooting-google-maps/#conflicts to dequeue ours and see if that resolves things for you.

    https://theeventscalendar.com/knowledgebase/implementing-custom-code-snippets/ can help you understand how to implement custom code snippets.

    Please let me know how this goes for you.

    #1592737
    Lou
    Participant

    deregister of ‘tribe-gmaps’ seems to have solved the problem. What features am I losing with that? Is it just the “view as map” view?

    BTW, I modified what was in https://theeventscalendar.com/knowledgebase/troubleshooting-google-maps/#conflicts to the following in my theme’s functions.php file. Seems as if the theme should verify the plugin is active before trying to deregister something, but maybe nothing bad will happen without the check.

    /**
     * Unregisters the Google Maps API script on Events Calendar PRO.
     */
    if ( is_plugin_active('events-calendar-pro/events-calendar-pro.php') ) {
    	add_action( 'wp_print_scripts', 'ecp_remove_google_maps_api', 100 );
    
    	function ecp_remove_google_maps_api() {
    		wp_deregister_script( 'tribe-gmaps' );
    	}
    }
    #1593448
    Cliff
    Member

    Thanks for the update, Lou.

    No, you don’t have to first check for the plugin to be active for this particular snippet.

    With that in place, our Google Maps script won’t load on your site. The lost functionality could include:

    • geocoding Venue addresses
    • Map View and/or Map View’s geolocating
    • Venue maps displayed wherever (Single Event pages, Single Venue pages)

    Please let me know if you have any follow-up questions on this topic.

    #1593613
    Lou
    Participant

    That’s unfortunate because we use some of that functionality.

    This is more of a basic wordpress question, but do you recommend a way to deregister ‘tribe-gmaps’ ONLY from certain pages?

    #1594430
    Cliff
    Member

    Please try it out and report back a URL for each page type that’s not working for you, such as all event views or just map view, single event pages, venue pages, etc.

    Maybe things will work more than I said because of your theme loading the script. Once you report back which views are/not working for you, we might be able to suggest a different snippet for your situation.

    Of course, we always recommend restorable database and file backups as well as performing modifications first on a staging site before modifying anything on your live/production site.

    #1594526
    Lou
    Participant

    I have made the update on both sandbox and production servers, https://sandbox.steeplechasers.org/training/running-routes/ and https://steeplechasers.org/training/running-routes/ respectively.

    A previously configured single event view looks ok. I also configured a new event with a new venue https://sandbox.steeplechasers.org/events/test-event/ and it looks fine as well.

    In Events > Settings > Display, I allowed Map view and when looking at the user map view it doesn’t work (as I expected). I see white screen for map. (Inexplicably when I added Map view my default view changed from Month to List. Going back in to settings I changed the default view back to month, and this seemed to stick.)

    > Maybe things will work more than I said because of your theme loading the script.

    Note my theme doesn’t load the script “correctly” from a wordpress perspective. For this purpose, the google maps script is only loaded on the theme-specific template pages (i.e., using direct html, not wp_enqueue_script() ) which are involved with displaying the map. See https://sandbox.steeplechasers.org/training/running-routes/ and https://tinyurl.com/y9ovc9e8 for rendering of the two templates.

    Since Events Maps are working in most cases, I have to assume tribe-gmaps isn’t the only way TEC loads the google maps scripts, and somehow there is no conflict when tribe-gmaps is deregistered.

    Interestingly, when I go to the home page (or other random page, even the calendar overview) and inspect with developer tools I see no google maps script inclusion, but when I go to a page managed by TEC that displays a map (e.g., single event view) I do see the google maps scripts. I don’t have time to reverse engineer how Tribe does this, but seems better than always including the google maps scripts on all pages.

    #1594532
    Lou
    Participant

    I should have also said that seems like things are fine for my use case now. I will leave the solution as it stands, deregistering tribe-gmaps from functions.php.

    #1594910
    Cliff
    Member

    Thanks for your detailed replies. Is there more I can help with at this time, or are you squared away for now?

    #1594930
    Lou
    Participant

    I’m good now. Thanks for your help.

    #1595088
    Cliff
    Member

    Glad to hear and thanks for letting us know.

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Google Maps API errors with TEC Pro 4.4.30’ is closed to new replies.