Answer the question
In order to leave comments, you need to log in
How to get map center coordinates from markers array in react google maps?
Colleagues, good day, I can not find a solution unfortunately.
The bottom line is, there is a @react-google-maps/api package on the page I draw a map:
<div className="searchMap">
<LoadScript googleMapsApiKey={ mapConfig.key } >
<GoogleMap
mapContainerStyle={ containerStyle }
center={{
lat: -3.745,
lng: -38.523
}}
zoom={ zoom }
onLoad={ onLoad }
onUnmount={ onUnmount }
>
{
markers.map(({ lat, lng }, index) =>
<Marker
key={ index }
position={{ lat, lng }}
/>
)
}
</GoogleMap>
</LoadScript>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question