Open jvrousseau opened 10 years ago
Found a fix, but it's probably a bit too hacky for a PR.
Rather than eachLayer through an L.MultiPolygon then call getLlgs, I concatenated the coordinates from feature.geometry.coordinates[0] to get the same result: https://github.com/jvrousseau/leaflet-pip/blob/gh-pages/index.js
The example above now works when clicking on any polygon in the MultiPolygon.
Please don't close this issue if the issue isn't fixed.
Sorry about that!
The behavior that I am observing when using the packaged version of the library from https://unpkg.com/@mapbox/leaflet-pip@1.1.0/leaflet-pip.js , is that it is not detecting the point within multipolygons. Probably because is.Poly
is like so
function isPoly(l) { return l.feature && l.feature.geometry && l.feature.geometry.type && ['Polygon', 'MultiPolygon'].indexOf(l.feature.geometry.type) !== -1; }
This means the pointInMultiPolygon function is never called. A different version of isPoly
can be found here: https://github.com/mapbox/leaflet-pip/blob/gh-pages/site/bundle.js , though I don't know how to use it, and whether it would resolve the issue.
I'm having a weird issue with a MultiPolygon not returning the layer when clicking on said layer.
I've modified the example you created to highlight the issue I am seeing: http://rousseau.io/leaflet-pip/
Code for the site can be found here: https://github.com/jvrousseau/leaflet-pip/blob/gh-pages/site/site.js
Here is the GeoJSON for the polygon that is shown in the example: https://github.com/jvrousseau/leaflet-pip/blob/gh-pages/site/broken.js
Please let me know if there is any other information I can provide.
More than likely, I am either doing something wrong, or the GeoJSON is bad in some way, shape, or form. Please let me know if that's the case.