I'm creating a website with a big main map. I have some markers with popups working when I click on makers. But now, I want to open the popup with an external event. I use redux to maintain the markers state and I would like to open or not the popup depending on the maker state.
There is no open
or isOpen
attribute on the popup Component in react-leaflet like this :
<Marker position={[this.props.lat, this.props.lon]}>
<Popup open={this.state.isOpen} >
The popup content
</Popup>
</Marker>
and the Leaflet API provide nothing better...
I already succeed to add an event listener onMouseOver
with ref
like below but no more.
class Poi extends Component{
render(){
return (
<Marker position={[this.props.lat, this.props.lon]}
ref={marker=> { this.marker = marker }}
onMouseOver={() => {s.marker.leafletElement.bindPopup('Popup content').openPopup();}}>
</Marker>
)
}
Thank you for your help! PS: I'm really new to react so please be indulgent :-)