From 174b84662a4bc38b7596002245c37184df37538e Mon Sep 17 00:00:00 2001 From: Bo Lu Date: Thu, 7 Nov 2024 14:09:05 -0500 Subject: [PATCH] Update geosearch.tsx --- src/components/search/geosearch.tsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/components/search/geosearch.tsx b/src/components/search/geosearch.tsx index d65d5b9c..3816cf72 100644 --- a/src/components/search/geosearch.tsx +++ b/src/components/search/geosearch.tsx @@ -211,20 +211,12 @@ const GeoSearch = ( } const image=L.imageOverlay(url, bounds, {opacity: 1}).addTo(map); setImage(image); - //map.fitBounds(bounds); const zoomLevel = map.getZoom(); - // Calculate a more appropriate longitude offset for Canada (scale it based on zoom level) - const longitudeOffset = 0.5 * (zoomLevel / 10); // Adjust this formula for better control - // Adjust the center after the map is set console.log(center.lat) console.log(center.lng ) - console.log(longitudeOffset) console.log(zoomLevel) - - - const adjustedCenter = new LatLng(center.lat, center.lng - longitudeOffset); - + const adjustedCenter = new LatLng(center.lat, center.lng); // Set the view with the new center and zoom level map.setView(adjustedCenter, map.getZoom() > 5 ? map.getZoom() - 1 : map.getZoom()); //map.setView(center, map.getZoom()); @@ -310,7 +302,7 @@ const GeoSearch = ( const cardOpen = selected === event ? !open : true; setFootprintViewed(cardOpen); const result = - Array.isArray(results) && results.length > 0 && cardOpen ? results.find((r: SearchResult) => r.id === event) : undefined; + Array.isArray(results) && results.length > 0 && cardOpen ? results.find((r: SearchResult) => r.id === event) : undefined; setSelected(event); setOpen(cardOpen); selectResult(result);