Spaces:
Runtime error
Runtime error
Commit ·
8db209d
1
Parent(s): 3b0d00b
Fix autoZooming on changing search radius / search limit
Browse files- Added setShouldZoom prop to CenterMap component and it's set to false after every zoom.
- No more annoying auto zooming after every change in search parameter
- frontend/src/components/Map.js +4 -2
- main.py +0 -1
frontend/src/components/Map.js
CHANGED
|
@@ -92,7 +92,7 @@ const Map = ( { onMapClick, searchQuery, contentType, setSearchQuery, setSubmitt
|
|
| 92 |
const [shouldZoom, setShouldZoom] = useState(false);
|
| 93 |
|
| 94 |
// Using CenterMap component to handle centering (for summary/full apis) and for zooming (for wiki/nearby api)
|
| 95 |
-
const CenterMap = ({ position, coordinates, shouldZoom }) => {
|
| 96 |
const map = useMap();
|
| 97 |
useEffect(() => {
|
| 98 |
if (position && Array.isArray(position) && position.length === 2) {
|
|
@@ -109,8 +109,9 @@ const Map = ( { onMapClick, searchQuery, contentType, setSearchQuery, setSubmitt
|
|
| 109 |
maxZoom: 16,
|
| 110 |
duration: 3
|
| 111 |
});
|
|
|
|
| 112 |
}
|
| 113 |
-
}, [coordinates, map, shouldZoom]);
|
| 114 |
|
| 115 |
return null;
|
| 116 |
};
|
|
@@ -614,6 +615,7 @@ const Map = ( { onMapClick, searchQuery, contentType, setSearchQuery, setSubmitt
|
|
| 614 |
position={markerPosition}
|
| 615 |
coordinates={explorationMarkers.map((marker) => marker.position)}
|
| 616 |
shouldZoom={shouldZoom}
|
|
|
|
| 617 |
/>
|
| 618 |
{baseLayer === "satellite" && (
|
| 619 |
<>
|
|
|
|
| 92 |
const [shouldZoom, setShouldZoom] = useState(false);
|
| 93 |
|
| 94 |
// Using CenterMap component to handle centering (for summary/full apis) and for zooming (for wiki/nearby api)
|
| 95 |
+
const CenterMap = ({ position, coordinates, shouldZoom, setShouldZoom }) => {
|
| 96 |
const map = useMap();
|
| 97 |
useEffect(() => {
|
| 98 |
if (position && Array.isArray(position) && position.length === 2) {
|
|
|
|
| 109 |
maxZoom: 16,
|
| 110 |
duration: 3
|
| 111 |
});
|
| 112 |
+
setShouldZoom(false);
|
| 113 |
}
|
| 114 |
+
}, [coordinates, map, shouldZoom, setShouldZoom]);
|
| 115 |
|
| 116 |
return null;
|
| 117 |
};
|
|
|
|
| 615 |
position={markerPosition}
|
| 616 |
coordinates={explorationMarkers.map((marker) => marker.position)}
|
| 617 |
shouldZoom={shouldZoom}
|
| 618 |
+
setShouldZoom={setShouldZoom}
|
| 619 |
/>
|
| 620 |
{baseLayer === "satellite" && (
|
| 621 |
<>
|
main.py
CHANGED
|
@@ -162,7 +162,6 @@ def get_geodistance(payload: Geodistance):
|
|
| 162 |
content={"error": str(e)},
|
| 163 |
status_code=500
|
| 164 |
)
|
| 165 |
-
|
| 166 |
return JSONResponse(
|
| 167 |
content={
|
| 168 |
"distance": distance,
|
|
|
|
| 162 |
content={"error": str(e)},
|
| 163 |
status_code=500
|
| 164 |
)
|
|
|
|
| 165 |
return JSONResponse(
|
| 166 |
content={
|
| 167 |
"distance": distance,
|