Archived topic
Plugin Incompatability
3 replies · Started by Andy on August 24, 2018
Hi,
I'm having some issues getting maps to display when using this plugin: https://wordpress.org/plugins/leaflet-map/
If I put a shortcode on a post built with Gutenberg the map won't display, the div is there but empty. And I get the browser console error:
Uncaught TypeError: Cannot read property 'addLayer' of undefined
at e.addTo (leaflet.js:5)
at (index):177
at init (7d5ec.js:1)
However, if I put a shortcode on a post built using the classic editor the map displays fine. Using Health Check and Theme Switcha plugins I was able to determin that the issue only occurs with GP + GPP enabled.
I've added a map to the bottom of a post and given a link to the post in the URL field for this thread so you can see the error first hand. I've also reported the issue to the plugin developer. (Please ignore the map at the top of the post, this is being added using a different service)
Any help much appreciated.
Thanks,
Andy
ok, so it seems I was getting the issue with the map not displaying at the bottom of the post because I was also trying to display another map full-width after the header using ACF and an Element Hook.
Basically I have a Wysiwyg Editor ACF field for the map shortcode. I then call this field in the Element after_header hook like so:
<div><?php the_field('map'); ?></div>
And it's this implementation of the shortcode which causes the JS error and prevents the map from displaying. So I'm now thinking it's more likely an ACF field issue, but any advice would be appreciated.
ok nevermind, it appears I wasn't writing the map shortcodes correctly, closing thread.
Glad to hear you found the solution :)