I want to set multiple markers on google maps whenever any user clicking on any location in the map. I am using functional approach in my react app.
<LoadScript googleMapsApiKey={mapKey}>
<GoogleMap
mapContainerStyle={{
width: '100%',
height: '85vh',
}}
center={center}
zoom={19}
onClick={ev => {
console.log("latitide = ", ev.latLng.lat());
console.log("longitude = ", ev.latLng.lng());
}}>
<Polyline
path={trucks}
geodesic={true}
options=
{{
strokeColor: "blue",
strokeOpacity: 5,
strokeWeight: 4,
}}
/>
{trucks?.map((d, i) => (
<MarkerF key={i}
onLoad={onLoad}
position={d} />
))}
</GoogleMap>
</LoadScript>
</div> ```