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?
I agree to this request. Also it would be nice to see Toolset js minimized and combined.
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.
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 ????
Sorry for the delay - private reply fields are enabled here.
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.
Sorry, forgot about the IP restriction :/
Please, try again...
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.
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... !?
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.
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?
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.
Ok, I'll do the maps the new way 😉
Thank you for your help 🙂