Google Maps API issue
This topic contains 13 replies, has 3 voices, and was last updated by Stiofan O’Connor 5 years, 6 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: google maps api
-
AuthorPosts
-
May 22, 2019 at 8:34 am #487947
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.2However, 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.
May 22, 2019 at 10:41 am #487969Hello,
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: “May 22, 2019 at 10:50 am #487973This reply has been marked as private.May 22, 2019 at 11:39 am #488005This reply has been marked as private.May 22, 2019 at 11:42 am #488006Have changed the slug for The Events Calendar, but GD is still using Open Streetmaps instead of Google Maps.
May 22, 2019 at 11:47 am #488012This reply has been marked as private.May 22, 2019 at 11:51 am #488013I’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.
May 22, 2019 at 11:53 am #488016Remove 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.May 22, 2019 at 12:01 pm #4880251. 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.
May 22, 2019 at 6:40 pm #488116This reply has been marked as private.May 23, 2019 at 8:19 am #488329This reply has been marked as private.May 24, 2019 at 1:35 pm #488630Hello,
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
May 29, 2019 at 9:05 am #489725Hi 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.
May 29, 2019 at 10:21 am #489741Our 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
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket