Skip Navigation

[Resolved] Google Maps API also loads on pages not using it

This thread is resolved. Here is a description of the problem and solution.

Problem: Google Maps API is loading on pages that do not include any maps. If I disable Toolset Maps, the problem is resolved.

Solution: Disable the setting "Legacy support for maps" and format map and marker Views according to the most recent standards.

Relevant Documentation: https://toolset.com/documentation/user-guides/display-on-google-maps/

This support ticket is created 7 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 12 replies, has 3 voices.

Last updated by nevilP 7 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#541944

I use Views integration with Google Maps on two pages on my website, but can see that the Google Maps API loads on all pages. Is there a way to avoid this unnecessary waste of load-time?

#541959

I agree to this request. Also it would be nice to see Toolset js minimized and combined.

#542106

Hi, I just ran some tests locally to see if I can verify this issue, and I cannot replicate that problem with the latest Toolset plugins and a default theme like Twenty Seventeen. The maps API does not load unless I'm showing a View or a Post with an address field that contains an address.

Is it possible for you to temporarily disable non-Toolset plugins and switch to a default theme like Twenty Seventeen? This way we can confirm the problem is specific to Toolset. If that's no possible, at least try to temporarily disable WP Rocket and test again. I know that plugin does some magic to help optimize your site, and I'm curious if it has anything any effect on the API loading.

If it's still occurring, I'll need to do some more investigation in your wp-admin area to determine what's happening. I will enable private reply fields here so you can provide login credentials securely.

#542331

Hi Christian. I have now tried deactivating all plugins and switch to standard theme Twenty Fourteen but Google Maps still loads on all pages, so I'll send you my credentials in a private reply, so that you can test it your selves...

NB: Please make a private request again as it's back to normal reply - thanks ????

#542568

Sorry for the delay - private reply fields are enabled here.

#542693
Screen Shot 2017-06-28 at 4.02.34 PM.png

After logging in with those credentials, I am unable to load the wp-admin area. I'm seeing a 403 / forbidden error. Am I missing something? Is there an IP restriction or other security step to take?

Screenshot attached, I blurred your URL just in case it's private.

#542829

Sorry, forgot about the IP restriction :/
Please, try again...

#543033

Okay that works, thanks. Is there a reason to enable the legacy Map plugin? If you're creating a new site, this shouldn't be required:
/wp-admin/admin.php?page=toolset-settings&tab=maps

Also can you share the URL of the two pages where maps are used? I'm unable to find any address custom fields, so I'm a bit lost.

#543041

You find the maps on pages: /contact/ and /dealers /
...but you have to switch to my custom theme to see them as they are added to the page-2xx.php template files via this code and (on the dealer page) the "view-partners" view:

Contact page:

<div id="js-map-element"
	class="team-main"
	data-marker-title='Ledon A/S'
	data-marker-lat='55.2491234'
	data-marker-lon='8.9642887'>
	 <div id="js-main-map-canvas" class="google-maps team-map-height"></div>
</div>

Dealer page:

<div id="js-main-map-canvas" class="google-maps team-map-height"></div>

If I doesn't enable the legacy option, maps won't show... !?

#543103

Okay, I see better now thanks. The legacy code can't be managed on a page-by-page basis, unfortunately, so it's either always on or always off. The best solution is to turn it off, and recreate these map markers and maps using the latest guidelines for Toolset's Map and Markers fields:
https://toolset.com/documentation/user-guides/display-on-google-maps/

You'll see that it's much more integrated with Views now, and there is a lot less HTML code to write than what you currently have in place. Eventually when legacy code is unsupported, you'll need to do this anyway. If you need assistance with specific parts of the updates I can help out.

#543159

It was the only way to make maps with Views, at the time I made it 😉
But if I change it to follow the guide you linked to, does the API then only load on pages showing Google maps?

#543228

It was the only way to make maps with Views, at the time I made it
You did a great job! It's just time for an upgrade.

...does the API then only load on pages showing Google maps
Yes that's correct. You can try this out on a small scale, perhaps just one map on one specific page. Disable the legacy scripts, then you can confirm that the new API assets are only loaded as needed.

#543312

Ok, I'll do the maps the new way 😉
Thank you for your help 🙂

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.