Leaflet Widget has some issues when other DOM elements fire AJAX events (like when uploading images). It could throw bunch of error notices and could make other loaded JS files to not work properly.

Upon further investigation, the culprit is that the 'leaflet-draw' String map key becomes ['leaflet-draw', 'leaflet-draw'] Array key when some AJAX events on the current page are happening.

I've created a workaround/patch for this and the patch solves the following JS error notices, and may be more:
Uncaught TypeError: Cannot call method 'addLayer' of null
Uncaught TypeError: Cannot read property 'tools' of null
Uncaught TypeError: Cannot read property 'polyline' of undefined

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ranelpadon’s picture

ranelpadon’s picture

Attached is an additional patch when encountering errors from the Leaflet core. See related issue also here:
https://drupal.org/node/2111081

SocialNicheGuru’s picture

Status: Active » Needs review

because there is a patch I changed the status to "Needs review"

das-peter’s picture

Status: Needs review » Needs work

Well, this patches modules/contribs/leaflet_draw/js/leaflet_draw_input.js. We're not in control over that.
So according to what I see the approach and / or the location where this is handled has to be changed.

vlooivlerke’s picture

I have the same issue in the new 7.x-2.0-beta1

Cant use media browser with leaflet.wedget. The ajax gets broken when you add images.

scotwith1t’s picture

I'm super-confused here too. The patch is against some leaflet_draw module, which is not even mentioned in the docs. The only one I can find is a sandbox project, and surely you're not depending on a sandbox project and then not even mentioning it in the instructions? Please help?! This module doesn't work for us and we've got a pretty simple setup. The widget renders, I can click the pin icon in the corner, click to place a pin but then every mouse move throws a "Uncaught TypeError: Cannot set property '_leaflet_pos' of undefined" in the console.