Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 710
Henry Okonkwo Avatar asked Oct 22 '25 16:10

Henry Okonkwo


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!

like image 138
jabamataro Avatar answered Oct 25 '25 06:10

jabamataro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!