Flexberry / Leaflet-WFST

OGC WFS-T client layer for Leaflet.
http://flexberry.github.io/Leaflet-WFST/
MIT License
151 stars 50 forks source link

EditPopupToolbar #27

Closed carrbrpoa closed 8 years ago

carrbrpoa commented 8 years ago

I'm handling WFST's click event with the following code, like I saw in examples:

wfst.on('click', function (event) {
    new L.EditPopupToolbar(event.latlng).addTo(map, event.layer);
});

The problem is that the EditPopupToolbar only appears in the first click, even debugging and seeing that the event is being fired.

Any ideas?

Thanks in advance

kuzkok commented 8 years ago

No idea. Can you publish full code listing?

carrbrpoa commented 8 years ago

Found something!

It seems to be associated with Leaflet's version: your polygon geoJSON example is using Leaflet 0.7.3, while I was trying at least with 1.0.0.beta.1.

The problem is that with 1.0.0.beta.1 and above (at least), the following code of your EditToolbar.js is being executed when I click a polygon after the first time:

map.once('click', function () { // Line 65 of EditToolbar.js
    map.removeLayer(that);
});

plunkr with 1.0.0.beta.1 and your sample data. See how it works when you change to 0.7.3.

carrbrpoa commented 8 years ago

It's an expected behaviour.

So, the following modification in EditToolbar.js keeps the popup working as expected:

map.once('click', function (e) {
    map.removeLayer(that);
});
shape.once('click', function (e) {
    map.removeLayer(that);
    L.DomEvent.stopPropagation(e);
});