Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some areas of MultiPolygon not returning from pointInLayer #7

Open
jvrousseau opened this issue Jun 19, 2014 · 4 comments
Open

Some areas of MultiPolygon not returning from pointInLayer #7

jvrousseau opened this issue Jun 19, 2014 · 4 comments

Comments

@jvrousseau
Copy link

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.

@jvrousseau
Copy link
Author

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.

@tmcw
Copy link
Contributor

tmcw commented Jun 19, 2014

Please don't close this issue if the issue isn't fixed.

@tmcw tmcw reopened this Jun 19, 2014
@jvrousseau
Copy link
Author

Sorry about that!

@chintanp
Copy link

The behavior that I am observing when using the packaged version of the library from https://unpkg.com/@mapbox/[email protected]/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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants