I am working on developing a react-leaflet map that has multiple markers. My intention is to make popups open one by one with interval.
So, my markers are rendered by mapping an array and returning component
arr.map((item, i) => <CustomMarker isActive={isActive} data={item} key={i} />)
isActive is a value that says should popup be active.
<CustomMarker /> looks like this:
const CustomMarker = ({isActive, data}) => {
return (
<Marker position={data.position}>
<Popup>
<a href={data.url}>Go to this website</a>
</Popup>
</Marker>
)
}
I tried several things but none do work for me.
- Implement through
eventHandlers - Create custom icon using
L.divIcon()and write HTML with custom popup. However, popup was unclickable as it was a part of markers icon.
How can use isActive value to open popup?