Home › Forums › Calendar Products › Events Calendar PRO › Google Maps API errors with TEC Pro 4.4.30
- This topic has 12 replies, 2 voices, and was last updated 5 years, 9 months ago by Lou.
-
AuthorPosts
-
August 6, 2018 at 4:59 pm #1591519LouParticipant
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 )
August 7, 2018 at 2:43 pm #1592445CliffMemberHi, 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 error: https://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?
August 7, 2018 at 3:02 pm #1592461LouParticipantThanks 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.
August 7, 2018 at 3:39 pm #1592488CliffMemberSince 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.
August 8, 2018 at 3:41 am #1592737LouParticipantderegister 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' ); } }
August 8, 2018 at 8:02 pm #1593448CliffMemberThanks 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.
August 9, 2018 at 2:35 am #1593613LouParticipantThat’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?
August 9, 2018 at 8:21 pm #1594430CliffMemberPlease 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.
August 10, 2018 at 3:54 am #1594526LouParticipantI 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.
August 10, 2018 at 3:55 am #1594532LouParticipantI 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.
August 10, 2018 at 10:02 am #1594910CliffMemberThanks for your detailed replies. Is there more I can help with at this time, or are you squared away for now?
August 10, 2018 at 10:18 am #1594930LouParticipantI’m good now. Thanks for your help.
August 10, 2018 at 12:47 pm #1595088CliffMemberGlad to hear and thanks for letting us know.
-
AuthorPosts
- The topic ‘Google Maps API errors with TEC Pro 4.4.30’ is closed to new replies.