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
}