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


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

    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


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!

Answered By – jabamataro

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *