I'm building an app with Flutter and am trying to listen to the pan gestures of the map to get the center of the map view and place a pin on the center. The code I've tried is as follows:
void _setPanGestureHandler({HereMapController mapController}) {
_hereMapController.gestures.panListener = PanListener.fromLambdas(
lambda_onPan: (GestureState gestureState, Point2D panStartPoint,
Point2D panEndPoint, double panVelocity) {
if (gestureState == GestureState.begin) {
print("start pan");
} else if (gestureState == GestureState.end) {
var centerPointLat = _hereMapController.viewportSize.width / 2;
var centerPointLong = _hereMapController.viewportSize.height / 2;
GeoCoordinates geoCoordinates = _hereMapController
.viewToGeoCoordinates(Point2D(centerPointLat, centerPointLong));
if (geoCoordinates == null) {
return;
}
_addPoiMapMarker(geoCoordinates);
_getAddressForCoordinates(geoCoordinates);
} else if (gestureState == GestureState.update) {
print("pan updated");
} else if (gestureState == GestureState.cancel) {
print("pan cancelled");
}
});
}
The code is part of the search_app example and I've just added a panGesture listener to it.
On panning, I get the following in the debug console
W/PanGestureDetector(21446): [WARN ] PanGestureDetector - Invalid panning of zero duration but nonzero length, skipping
W/PanGestureDetector(21446): [WARN ] PanGestureDetector - Invalid panning of zero duration but nonzero length, skipping
Please let me know how I can solve this problem.