I'm trying to find out what is the bounding box of the visible part of google map in flutter's google maps plugin.
Is it possible to get it?
If not is it possible to calculate the bounding box based on zoom level and latitude, longitude of the map center?
Step 1: Add location and syncfusion_flutter_maps packages to your dependencies in pubspec. yaml file. Step 2: Import the below libraries in your dart file. Step 3: Using the public APIs in the Flutter location package, we can get the current location.
That would be GoogleMapController.getVisibleRegion()
Be careful, GoogleMapController.getVisibleRegion()
returns a LatLngBounds
(a rectangle) and if your map has a tilt then it should not be a rectangle but a trapezoid!
The issue is in the plugin implementation where the returned result is computed only from latLngBounds
field whereas it should be computed from farLeft
, farRight
, nearLeft
, nearRight
fields.
Reference: https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/VisibleRegion
So GoogleMapController.getVisibleRegion()
is not accurate and can't be used if there's a tilt.
For reference, an issue has been created: https://github.com/flutter/flutter/issues/74888
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With