Spaces:
Runtime error
Runtime error
Commit
·
7f14e86
1
Parent(s):
02e5929
Add auto centering of for queried location
Browse files
frontend/src/components/Map.js
CHANGED
@@ -83,6 +83,16 @@ const Map = ( { onMapClick, searchQuery, contentType } ) => {
|
|
83 |
|
84 |
const [countryBorders, setCountryBorders] = useState(null);
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
const handleMouseDown = (e) => {
|
87 |
isDragging.current = true;
|
88 |
startX.current = e.clientX;
|
@@ -515,6 +525,7 @@ const Map = ( { onMapClick, searchQuery, contentType } ) => {
|
|
515 |
<ScaleControl position="bottomright" imperial={true} />
|
516 |
|
517 |
<ResizeHandler trigger={wikiWidth} />
|
|
|
518 |
{baseLayer === "satellite" && (
|
519 |
<>
|
520 |
<TileLayer
|
|
|
83 |
|
84 |
const [countryBorders, setCountryBorders] = useState(null);
|
85 |
|
86 |
+
const CenterMap = ({ position }) => {
|
87 |
+
const map = useMap();
|
88 |
+
useEffect(() => {
|
89 |
+
if (position && Array.isArray(position) && position.length === 2) {
|
90 |
+
map.setView(position, map.getZoom());
|
91 |
+
}
|
92 |
+
}, [map, position]);
|
93 |
+
return null;
|
94 |
+
};
|
95 |
+
|
96 |
const handleMouseDown = (e) => {
|
97 |
isDragging.current = true;
|
98 |
startX.current = e.clientX;
|
|
|
525 |
<ScaleControl position="bottomright" imperial={true} />
|
526 |
|
527 |
<ResizeHandler trigger={wikiWidth} />
|
528 |
+
<CenterMap position={markerPosition} />
|
529 |
{baseLayer === "satellite" && (
|
530 |
<>
|
531 |
<TileLayer
|