onPanning method
Called whenever panning is happening.
Subclasses can override this method to do any custom operations based on
the details provided in the MapPanDetails. When
super.onPanning(details)
is not called, panning will not happen.
MapPanDetails contains following properties.
- MapPanDetails.previousVisibleBounds - provides the visible bounds before the current panning operation completes i.e. current visible bounds.
- MapPanDetails.newVisibleBounds - provides the new visible bounds
when the current pan completes. Hence, if the
super.onPanning(details)
is not called, there will be no changes in the UI. - MapPanDetails.zoomLevel - provides the current zoom level.
- MapPanDetails.delta - The difference in pixels between touch start and current touch position.
- MapPanDetails.globalFocalPoint - The global focal point of the pointers in contact with the screen.
- MapPanDetails.localFocalPoint - The local focal point of the pointers in contact with the screen.
Implementation
void onPanning(MapPanDetails details) {
if (_controller != null) {
_latLngBounds = details.newVisibleBounds;
if (_controller!.layerType == LayerType.shape) {
_controller!.notifyPanningListeners(details);
_controller!.notifyListeners();
} else {
_controller!
..isInInteractive = true
..gesture = Gesture.pan
..localScale = 1.0
..panDistance += details.delta!;
focalLatLng = details.focalLatLng;
_controller!.notifyListeners();
}
}
}