i want to get the coordinates of google map react onclick. this is my code :
return (
<GoogleMapReact
google={this.props.google}
styles={customizeMap}
style= {ukuran}
zoom={15}
onClick={(e) => {
console.log("latitude = ", e.latLng.lat());
console.log("longtitude = ", e.latLng.lng());
}}
initialCenter={!!this.props.places && this.props.places ? (
{ lat: this.props.places.lat, lng: this.props.places.lng}
):({ lat: -7.747872, lng: 110.4218147 })}>
<Marker
position={!!this.props.places && this.props.places ? (
{ lat: this.props.places.lat, lng: this.props.places.lng}
):({ lat: -7.747872, lng: 110.4218147 })}
icon={{
url: Icon,
scaledSize: new this.props.google.maps.Size(70, 55)
}}
/>
</GoogleMapReact>
);
and this is the message returned on the console:
Uncaught TypeError: Cannot read properties of undefined (reading 'lat')
at Object.onClick (halteMap.js:58:1)
at index.js:311:1