From 0c1a1dc82a710310d1ba8ab8ca5a9efc8c42623f Mon Sep 17 00:00:00 2001 From: Arman9009 Date: Fri, 26 Sep 2025 12:46:41 +0400 Subject: [PATCH] fit markers into borders for map component --- src/Body/Fields/Map/Map.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Body/Fields/Map/Map.js b/src/Body/Fields/Map/Map.js index e3431a4f..fadeecdc 100644 --- a/src/Body/Fields/Map/Map.js +++ b/src/Body/Fields/Map/Map.js @@ -33,6 +33,9 @@ const Map = ({ zoom: zoom, mapId: `${Math.floor(Math.random() * 1000000)}` }) + + const bounds = new google.maps.LatLngBounds() + markers.map(item => { const { position, description } = item const marker = new AdvancedMarkerElement({ @@ -49,9 +52,13 @@ const Map = ({ shouldFocus: false }) }) + + bounds.extend(position) }) + + map.fitBounds(bounds) }) - }, [zoom]) + }, [zoom, markers]) return
}