Title: Gutenberg Error
Last modified: August 23, 2018

---

# Gutenberg Error

 *  Resolved [andyt1980](https://wordpress.org/support/users/andyt1980/)
 * (@andyt1980)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/gutenberg-error/)
 * Hi,
    When adding a leaflet map shortcode to a post built using the Guteberg editor
   the map doesnt display and gives the following browser console error:
 * Uncaught TypeError: Cannot read property ‘addLayer’ of undefined
    at e.addTo (
   leaflet.js:5) at (index):177 at init (97909.js:1)
 * I can confirm if I switch to a post created with the classic wordpress editor
   the map displays fine.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [bozdoz](https://wordpress.org/support/users/bozdoz/)
 * (@bozdoz)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/gutenberg-error/#post-10619464)
 * Sounds interesting. I cannot recreate this. Could you give me more details on
   the theme you’re using perhaps?
 * Check out my screenshots:
 * > [View post on imgur.com](https://imgur.com/5zLQCFg)
 * > [View post on imgur.com](https://imgur.com/ldeX0Od)
 *  Thread Starter [andyt1980](https://wordpress.org/support/users/andyt1980/)
 * (@andyt1980)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/gutenberg-error/#post-10620622)
 * Hmmm, thats strange, I’m using Generatepress which is generally regarded as a
   very well coded theme as it always adheres to WordPress coding standards. I would
   have said its a plugin causing the issue but how would it still work in the classic
   editor?
 *  Thread Starter [andyt1980](https://wordpress.org/support/users/andyt1980/)
 * (@andyt1980)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/gutenberg-error/#post-10620952)
 * Whats really odd is if I press the preview button in the editor the map displays
   on the preview page, but if I press update and publish the change it doesn’t 
   display on the published page. The div wrapper is there, just empty.
 *  Thread Starter [andyt1980](https://wordpress.org/support/users/andyt1980/)
 * (@andyt1980)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/gutenberg-error/#post-10621142)
 * 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 a Advanced Custom Fields to ‘inject’ the map after the header
   using a theme hook.
 * Basically I have a Wysiwyg Editor ACF field for the map shortcode. I then call
   this field in the 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.
 *  Thread Starter [andyt1980](https://wordpress.org/support/users/andyt1980/)
 * (@andyt1980)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/gutenberg-error/#post-10621269)
 * ok nevermind it appears I wasn’t writing the shortcodes correctly.
 * Now I’ve been able to test the plugin/maps correctly I have a few queries.
 * – When adding a GPX is there no way for the map to zoom to the area where the
   GPX is located without having to manually add an address or coordinates?
    – I
   disabled mousewheel zoom and drag as I will be using full-width maps and don’t
   want people getting stuck on maps. When testing on mobile (safari), if you interact
   with the map using the zoom controls or pinch zooming then there is a delay before
   you can scroll past the map again. Ideally it would use this gesture handling
   leaflet plugin: [https://github.com/elmarquis/Leaflet.GestureHandling](https://github.com/elmarquis/Leaflet.GestureHandling)
   Demo – [https://elmarquis.github.io/Leaflet.GestureHandling/examples/](https://elmarquis.github.io/Leaflet.GestureHandling/examples/)
   This still allows scrollzoom on desktop and works perfectly on mobile
    -  This reply was modified 7 years, 9 months ago by [andyt1980](https://wordpress.org/support/users/andyt1980/).
    -  This reply was modified 7 years, 9 months ago by [andyt1980](https://wordpress.org/support/users/andyt1980/).
 *  Plugin Author [bozdoz](https://wordpress.org/support/users/bozdoz/)
 * (@bozdoz)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/gutenberg-error/#post-10621584)
 * I was working on a function to zoom to all relevant layers, but I don’t think
   it’s finished. You could set the map center to the location, but I agree it’s
   not a great solution for dynamic maps. I’m not aware of a mobile delay.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Gutenberg Error’ is closed to new replies.

 * ![](https://ps.w.org/leaflet-map/assets/icon-256x256.png?rev=1693083)
 * [Leaflet Map](https://wordpress.org/plugins/leaflet-map/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/leaflet-map/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/leaflet-map/)
 * [Active Topics](https://wordpress.org/support/plugin/leaflet-map/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/leaflet-map/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/leaflet-map/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [bozdoz](https://wordpress.org/support/users/bozdoz/)
 * Last activity: [7 years, 9 months ago](https://wordpress.org/support/topic/gutenberg-error/#post-10621584)
 * Status: resolved