flutter_map
flutter_map copied to clipboard
Add option to snap/spring to nearest integer zoom level (if close)
What do you want implemented?
Say the user stops zooming and they are VERY CLOSE to a higher resolution set of tiles. You can set a small threshold say within 0.10 of the clamped zoom level, and if they are within that small range after they are done zooming, "snap" to the higher zoom. It could default to off but allow use to enable and set the threshold value.
For example, I do this in my onPositionChanged:
stopOpcAutoZoomTimer();
if (zoomingMap) {
_opcAutoZoomTimer = Timer(Duration(milliseconds: 64), () async {
double maxZoomLevel = 10;
// Snaps to nearby higher-res zoom level if close enough
for (double level = 4; level <= maxZoomLevel; level++) {
double threshold = level + 0.5;
if (mapState.zoom > threshold - 0.1 && mapState.zoom < threshold) {
stopPositionChangedTimer();
mapState.move(
LatLng(centerPosition.latitude, centerPosition.longitude), threshold);
break;
}
}
});
}
Not sure what optimal timer duration would be, but you could leave it up to the user.
What other alternatives are available?
No response
Can you provide any other information?
No response
I think for the time being, this is some unnecessary complexity to add to the core, since as you've demoed, it's not too difficult to DIY. It would be quite nice to have some sort of springing mechanism, but getting it right might take some time.
I'm going to leave this open as low priority for now.