Michael-M-aher / location_picker_flutter_map

A Flutter package that provides Place search and Location picker for flutter maps with alot of cusomizations using Open Street Map.
MIT License
23 stars 48 forks source link

Restrict selectable location to specified area #37

Closed giaur500 closed 2 months ago

giaur500 commented 8 months ago

I need to restrict location allowed to be selected to specified area. So I need to:

Is there any way to do that, or that functionality needs to be added? As I can see, there's some callback methods called on position change, so they could be used to check if current position is inside city border and possibly block selecting location outside the city, can I also draw anything I need on map (city border in this case).

Michael-M-aher commented 2 months ago

now on version 3.1.0 you can find mapLayers attribute and you can add polygon layer or any layer you want to throw meassage you can use any service you want and validate the picked location in the onPicked or onChanged

giaur500 commented 2 months ago

you can use any service you want and validate the picked location in the onPicked or onChanged

I know which polygon should be validated, I know its coordinates. I don't know what do you mean by "any service" - I still need to calculate if picked location is inside polygon or not. As I understand, you mean version 3.1.0 introduces easier way to access polygon, right? Or, your lib is able to check it automatically and throw exception? Please clarify - I am able to draw polygon, but I still need to validate location by myself?

For that purpose, I forked your lib and I just added polygon draw feature + validation location is inside polygon or not.

Michael-M-aher commented 2 months ago

To validate location you need to impliment point-in-polygon algorithm