Skip to content

Commit

Permalink
Map: Pan to center of markers on load for UX
Browse files Browse the repository at this point in the history
  • Loading branch information
iandunn committed Nov 20, 2023
1 parent 09bd2a1 commit 711ed97
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mu-plugins/blocks/google-map/src/components/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ export default function Map( { apiKey, markers: rawMarkers, icon } ) {
icon
);

panToCenter(
combinedMarkers.map( ( marker ) => marker.markerRef ),
googleMap.current,
googleMapsApi.current
);

setLoaded( true );
}, [] );

Expand Down

0 comments on commit 711ed97

Please sign in to comment.