1

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

2 Answers2

1

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

Ajantha Bandara
  • 1,473
  • 15
  • 36
0

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.

http://googlemaps.github.io/android-maps-utils/javadoc/

Victor Eronmosele
  • 7,040
  • 2
  • 10
  • 33