Hi I am working on app in which i want to know if the user is inside the polygon or not. kinly help with the code.
thank you
Hi I am working on app in which i want to know if the user is inside the polygon or not. kinly help with the code.
thank you
I'm using google_maps_utils plugin to check the given location is inside the polygon or not. Also this plugin provides other use-full utils as well
You can use the maps_toolkit package's PolygonUtil.containsLocation
method to do check if a particular point is in a polygon.
Here's a sample code:
LatLng point = LatLng(37.4221, 122.0841);
List<LatLng> polygonPoints = [LatLng(14.4, 12.0), LatLng(50.9, 70.56), LatLng(45.3, 130.0)];
bool geodesic = true;
PolygonUtil.containsLocation(point, polygonPoints, geodesic);
For the geodesic
property above,
The polygon is formed of great circle segments if geodesic is true, and of rhumb (loxodromic) segments otherwise.