Check if a coordinate is inside a polygon in flutter using google_maps_flutter

Viewed 1355

I using google_maps_flutter library on my flutter project, I created a polygon but i wanted to check if a coordinate is within a polygon... how can i do this?

That is google widget

GoogleMap(
    myLocationButtonEnabled: false,
    myLocationEnabled: true,
    mapToolbarEnabled: false,
    polygons: myPolygon(),
    mapType: MapType.normal,
    initialCameraPosition: _initialCamera,
    onMapCreated: _onMapCreated,
    onCameraMove: _onCameraMove,
    onCameraIdle: _onCameraIdle,
),

Please how can i check if a coordinate is within the polygon

1 Answers

You can use the PolyUtil.containsLocation method on the Maps SDK for Android Utility Library. Here is the reference documentation.

And, with flutter, you can use all PolyUtil methods that are available in google map utility class PolyUtil by using the google_map_polyutil 1.0.0 package that can be found here.

I hope this helps!

Related