As you already have handleToggle1
function setting the isMarkerVisible flag then on render()
you can have this:
render() {
const markers = this.state.isMarkerVisible ? this.props.policeCall : []
... <your code>
return <div>
... <your code>
{markers.map(({ A, B, M, N, L,O }) => {
return (
<Marker
onClick={this.onMarkerClick}
name={A}
info={B}
priority={L}
position={{ lat: M, lng: N }}
story={O}
/>
);
})}
... <your code>
</div>
}
All the ellipsis is your code but for brevity I only added where you will need to make changes to toggle markers.
3
solved A toggle button on and off for markers in google maps react