lami
lami

Reputation: 11

How to detect a change in zoom level when using MapBox in Flutter?

There seem to be no straightforward way of detecting a change in the zoom level when using MapBox in Flutter. Various references exist for implementations outside Flutter or on for native SDK's, but their counterparts for Flutter are not easy to find. Kindly point me to documentation or a code example to detect a change in zoom level.

Upvotes: 1

Views: 1305

Answers (2)

user1445685
user1445685

Reputation: 883

first set trackCameraPosition to true on your map, then in your styleloaded callback:

controller.addListener(() {
    print(controller.cameraPosition.zoom);
});

Upvotes: 2

Arslan Kaleem
Arslan Kaleem

Reputation: 1618

you can user MapboxMapController to detect zoom.. first you have to create _onMapCreated function which updates the controller and then you can add listener to controller like

controller.addListener(() {
      print(controller.cameraPosition.zoom);
    });

Upvotes: 0

Related Questions