Skip to content

L.Popup doesn't fire 'popupclose' event when using multipolygon features #1681

@kingrollo

Description

@kingrollo

Not sure what the logic is, but I have a GeoJSON layer which I switched from a standard polygon dataset to an aggregate (multipart / multipolygon) polygon dataset. I have a listener for popupclose:

                    popup.on('popupclose', function(e) {
                        ...
                    });

... which stopped working when I made the switch, and worked fine again when I switched back.

No errors are thrown to the user when it fails, the event just doesn't get fired.

Firefox / Windows / v0.6 beta (downloaded 8th May), and the problem also occurs in IE8. In 0.5.1 neither works, so I couldn't create a working demo in JSFiddle, but if you paste the code below into a test website and alternate between the two GeoJSON examples, you should see what I mean:

<link rel="stylesheet" href="libs/leaflet/leaflet.css">
<script src="libs/leaflet/leaflet.js"></script>
<div id="map" style="height: 300px"></div>
<script>
var map = new L.Map("map", {
    center: new L.LatLng(1, 1),
    zoom: 14
});

var geojson = {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[1.001,1.001],[1.001,0.999],[0.999,0.999],[0.999,1.001],[1.001,1.001]]]},"properties":{"works": "My close event works fine..."}}]};
//var geojson = {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[1.001,1.001],[1.001,0.999],[0.999,0.999],[0.999,1.001],[1.001,1.001]]]]},"properties":{"works": "Mine doesn't..."}}]};


var lyr = L.geoJson(geojson, {
    style: { weight : 1 },
    onEachFeature : function(feature, layer) {
        var popup = layer.bindPopup(feature.properties.works);
        popup.on("popupclose", function(e) {
            alert("Hi!");
        });
    }
}).addTo(map);
</script>

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions