Skip to content

Commit 9bcda14

Browse files
fatbirdray-oxd
authored andcommitted
DBC22-5228 clicking my location always pans to user's location
1 parent ba8bc83 commit 9bcda14

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/frontend/src/Components/map/Map.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,21 @@ export default function DriveBCMap(props) {
370370
const [showLocationAccessError, setShowLocationAccessError] = useState(false);
371371

372372
const loadMyLocation = () => {
373+
// per DBC22-5228, clicking button always moves to user's current location
374+
if ('geolocation' in navigator) {
375+
navigator.geolocation.getCurrentPosition((position) => {
376+
const { latitude, longitude } = position.coords;
377+
if (
378+
position.coords.longitude <= -113.7 &&
379+
position.coords.longitude >= -139.3 &&
380+
position.coords.latitude <= 60.1 &&
381+
position.coords.latitude >= 48.2
382+
) {
383+
setZoomPan(mapView, 9, fromLonLat([longitude, latitude]));
384+
}
385+
});
386+
}
387+
373388
if (!locationSet.current) {
374389
setMyLocationLoading(true);
375390
} else {

src/frontend/src/Components/map/helpers/map.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export const toggleMyLocation = (mapRef, mapView, setMyLocationLoading, setMyLoc
112112
};
113113

114114
setMyLocation(myLocation);
115-
setZoomPan(mapView, 9, fromLonLat([longitude, latitude]));
116115
setMyLocationLoading(false);
117116

118117
} else {

0 commit comments

Comments
 (0)