Get Camera

The MapCamera object describes the map's current viewport. It does not provide methods to change it: that is the responsibility of a MapController.

The MapCamera object also provides access to some other helpful methods that depend on it, such as pointToLatLng & latLngToPoint.

Usage Inside Of A FlutterMap Child

To get the camera from within the context of a FlutterMap widget, use MapCamera.of(context).

If this behaviour is unwanted, use Single Time instead.

If this throws a StateError, try wrapping the concerned widget in a Builder, to ensure the FlutterMap widget is parenting the BuildContext. If this has no effect, use Usage Outside Of FlutterMap instead.

Usage Outside Of FlutterMap

Single Time

Then, use the .camera getter.

Avoid using MapController.of(context).camera from within the context of FlutterMap, as it is redundant and less performant than using MapCamera.of(context) directly.

Listen To Changes

pageListen To Events

Last updated

© flutter_map Authors & Maintainers