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

onTap or onPress for Polygon? #1

Closed
jasonflaherty opened this issue Feb 6, 2023 · 2 comments
Closed

onTap or onPress for Polygon? #1

jasonflaherty opened this issue Feb 6, 2023 · 2 comments

Comments

@jasonflaherty
Copy link

Just checking out your library here! Cool stuff. I don't see onTap/press for Polygons. Am I missing it? Thanks!

@jozes
Copy link
Owner

jozes commented Feb 6, 2023

Hi @jasonflaherty!

You are right, there is no onTap functionality for polygons. The reason is that this functionality should be implemented as method of Polygon class in flutter_map package.
Of course one can implement this functionality as kind of extension to Polygon class. The main problem I see here is that we should not duplicate the polygon data - the outer and potential inner rings (holes) consisting of points. IMHO each Polygon should have implemented a property called MBR (Minimum Bounding Rectangle) which is calculated from the points in outer and inner rings. When the user clicks on the map then we can check with 4 "if" comparisons if the clicked point is inside the polygon's MBR and if that is true then the actual point-in-polygon test can be conducted to determine if the point is really inside the polygon. Such implementation would dramatically shorten the amount of time required to traverse the list of polygons. Even better would be to build a spatial index on top of polygons or MBRs which could then be quickly accessed and candidate polygons found.
If we would duplicate all data and not use some advanced method to eliminate false candidates quickly the onTap method could take a lot of processing, especially when there are thousands of polygons to be searched through.

The main purpose of this package is parsing the GeoJson and creating map objects. Unfortunately the Polygon class has no onTap method so I hope that this will be implemented in future. Currently I have no plans to implement this functionality.

@beeekey
Copy link

beeekey commented Feb 19, 2023

Is there any hack for this problem? I need the same.

@jozes jozes closed this as completed Mar 16, 2023
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