fysoul17 / google_maps_place_picker

Place picker on Google Maps for Flutter
MIT License
223 stars 364 forks source link

Restrict to defined area #28

Closed giaur500 closed 4 years ago

giaur500 commented 4 years ago

I have city area defined as geojson. I need to restrict available area to my city only and show message when user tries to pick address outside city area. City boundary should also be visible on map to get user to know about suppoeted area.

My proposal:

Might be useful: https://pub.dev/packages/geojson

fysoul17 commented 4 years ago

Hi,

I have no idea how to implement the package you suggested. City boundary is also not supported by google map.

In addition, your usecase is a very case-specific task and thus I suggest you to fork the project and implement on your end. You can also implement your forked repo into your project using pubspec.yaml.

I am sorry that I cloud not help you with your case.

fysoul17 commented 4 years ago

A closed issue you might want to see here.

giaur500 commented 4 years ago

Actually, implementation is pretty easy in my opinion. All you need is to draw geojson (Google Maps plugin supports polygons and other shapes drawing) and when user pick location, check whenever latitude/longitude is inside polygon (from geojson) or not. That has nothing to do with Google Map, only geojson feature parsing. To be more specific I have boundary geojson by myself, as string, only need to draw it and deternine if chosen location is inside polygon or not.

Well, that may look as case specific, but still, you should consider some kind of restrictions allowed area.

I think I will need to fork your plugin then to add these features.

giaur500 commented 3 years ago

I have managed to fork it and add following functionalities:

geojson_vi and geodesy libraries have been used to parse/draw geojson and determine if selected location is inside allowed area or not.

I think I can create PR, but my fork is based on older version. The trick is to extract shape from geojson string and generate polyline, which is supported by Google Maps, then draw it.