Is there a way to get callbacks for mapGestureInteractionStarted and mapGestureInteractionStopped? onPositionChanged should give results in between these two callbacks. I am doing some heavy work after the mapPosition changes. But currently the only way to understand this is by too many small updates. This slows things a lot. I would like to know when the user takes his/her hands on/off the map ie stop pan/zoom and do the heavy work only after this. I am mainly working on clustering.
Optionally, is there another way to accomplish this by using debouncing? When the first onPositionChanged happens, mapGestureInteractionStarted state can be set, and after a certain time passes without any more onPositionChanged, mapGestureInteractionStopped state can be set. Is this good practice? This would also cover the cases when the user is still continuing to touch the map but does not move/zoom it. Like a pause gesture.
Currently I'm using a throttling method to workaround the mapGestureInteractionStarted and mapGestureInteractionStopped.
Timer _timer;
bool _gestureStart = true;
void _restartTimer() {
_gestureStart = false;
_timer?.cancel();
_timer = Timer(Duration(milliseconds: 100), () {
_gestureStart = true;
// mapGestureInteractionStopped callback here
});
}
And on your FlutterMap onPositionChanged
onPositionChanged: (_) {
if (_gestureStart) {
// mapGestureInteractionStart callback here
}
_restartTimer();
}
FlutterMapState uses the MapGestureMixin class that could emit events through MapState (in addition to calling move())
@johnpryan can you show a small snippet of code(could be pseudo) how we would access those events from our view controllers?
Most helpful comment
Currently I'm using a throttling method to workaround the mapGestureInteractionStarted and mapGestureInteractionStopped.
And on your FlutterMap onPositionChanged