I'm trying to add an in app map to my application. In this I need to add a button which will console log ("Hi I'm here") when clicked.
Package used here is "react-google-maps"
const handleOnLoad = GoogleMap => {
const controlButtonDiv = document.createElement('div');
ReactDOM.render(<CustomControl onClick={() => console.log('Hi I'm Here')} />, controlButtonDiv);
GoogleMap.controls[window.google.maps.ControlPosition.TOP_RIGHT].push(controlButtonDiv);
};
<GoogleMap
defaultZoom={16}
defaultCenter={{ lat: this.props.latVal, lng: this.props.longVal}}
onTilesLoaded={GoogleMap => handleOnLoad(GoogleMap)}
>
<Marker
position={this.state.progress[this.state.progress.length - 1]}
icon={{
url: 'https://images.vexels.com/media/users/3/154573/isolated/preview/bd08e000a449288c914d851cb9dae110-hatchback-car-top-view-silhouette-by-vexels.png',
scaledSize: new window.google.maps.Size(50, 50),
anchor: { x: 10, y: 10 }
}}
/>
<Polyline
path={this.state.progress}
options={{ strokeColor: "#FF0000" }}
/>
<Circle
defaultCenter={{lat: this.props.latVal, lng: this.props.longVal}}
radius={parseInt(this.props.geofence)}
options={{strokeColor: "#ff0000"}}
/>
</GoogleMap>