From df96c4202b7b2df8460a0f099592c7896eeb03c8 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 3 Apr 2024 13:54:44 -0700 Subject: [PATCH] DBC22-528: fix double panning on click --- src/frontend/src/Components/Map.js | 16 ++++++---------- src/frontend/src/Components/map/helper.js | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/frontend/src/Components/Map.js b/src/frontend/src/Components/Map.js index 7309062d8..e01742a31 100644 --- a/src/frontend/src/Components/Map.js +++ b/src/frontend/src/Components/Map.js @@ -118,6 +118,7 @@ export default function MapWrapper({ restStops, restStopsTimeStamp, // Rest Stops searchLocationFrom, + searchLocationTo, selectedRoute, // Routing zoom, pan, // Map @@ -146,6 +147,7 @@ export default function MapWrapper({ restStopsTimeStamp: state.feeds.restStops.routeTimeStamp, // Routing searchLocationFrom: state.routes.searchLocationFrom, + searchLocationTo: state.routes.searchLocationTo, selectedRoute: state.routes.selectedRoute, // Map zoom: state.map.zoom, @@ -623,17 +625,11 @@ export default function MapWrapper({ // store the initial searchLocationFrom.[0].label so that subsequent // runs can be evaluated to detect change in the search from isInitialMountLocation.current = searchLocationFrom[0].label; - } else if ( - isInitialMountLocation.current !== searchLocationFrom[0].label - ) { - // only zoomPan on a real change in the search location from; this makes - // this effector idempotent wrt state + + // only zoomPan on from location change when to location is NOT set + } else if (isInitialMountLocation.current !== searchLocationFrom[0].label && searchLocationTo.length == 0) { isInitialMountLocation.current = false; - setZoomPan( - mapView, - 9, - fromLonLat(searchLocationFrom[0].geometry.coordinates), - ); + setZoomPan(mapView, 9, fromLonLat(searchLocationFrom[0].geometry.coordinates)); } } else { // initial location was set, so no need to prevent pan/zoom diff --git a/src/frontend/src/Components/map/helper.js b/src/frontend/src/Components/map/helper.js index 7f6353545..0a473354f 100644 --- a/src/frontend/src/Components/map/helper.js +++ b/src/frontend/src/Components/map/helper.js @@ -69,7 +69,7 @@ export const setZoomPan = (mapView, zoom, panCoords) => { } const args = { - duration: 750 + duration: 1000 }; if (zoom) {