I have custom markers added to react google map. What I am trying to do is to add custom marker on one that user clicks. I tried to use state, set it to false and then change to true when is clicked but no luck.
Here is the marker part of Map
import Pin from "../img/pin.svg";
import activePin from "../img/activePin.svg";
{marker.map(marker => (
<Marker key={marker.id}
position={{
lat: marker.lat,
lng: marker.lng
}}
icon={{
url: this.props.showActive ? Pin : activePin
}}
onClick={e => {
this.activatePin(marker);
}}
/>
))}
Assume that Pin and activePin are variables with paths to image. Markers, their lat and lng I am getting from API.
Currently click not change icons, it just stay as regular icon. Should I use withStateHandlers or is there another way?