Skip to content

Zoom change event listener. #935

Answered by vnmiso
macik1423 asked this question in Q&A
Discussion options

You must be logged in to vote

You can listen to map events and try to determine whether a zoom occurred there, until this functionality is implemened.
For example:

class MyMap extends StatelessWidget {
  // To be able to access the current zoom level at all times. Not strictly
  // needed, you can omit this.
  final _mapController = MapController();

  @override
  Widget build(BuildContext context) {
    return FlutterMap(
      options: MapOptions(onMapEvent: _handleMapEvent),
      mapController: _mapController,
    );
  }

  void _handleMapEvent(MapEvent event) {
    double? oldZoom;
    double? newZoom;

    // event.targetZoom should be the same as _mapController.zoom
    if (event is MapEventWithMove) {
      ol…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JaffaKetchup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants