'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.
Solution 1:[1]
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);
});
Solution 2:[2]
first set trackCameraPosition to true on your map, then in your styleloaded callback:
controller.addListener(() {
print(controller.cameraPosition.zoom);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Arslan Kaleem |
Solution 2 | user1445685 |