I try to use the event .isOpen does not update its status when I click on my popup. Someone know why or know how to do ?
This is my code :
class Map extends React.Component {
constructor(props) {
super(props);
this.state = {
x: 0,
y: 0,
geojsonData: null,
geojsonData6: null,
}
}
initMap() {
//Declaration of the map
var valMarker = L.marker([this.state.y, this.state.x]).addTo(this.state.map)
.bindPopup('Hotel "Port de Calais"<br> 7 circuits à proximités.')
var valPopup = valMarker.getPopup()
if (valPopup.isOpen() === true) {
var myData = [this.state.geojsonData, this.state.geojsonData6]
L.geoJSON(myData).addTo(this.state.map)
}
}
componentDidMount() {
this.initData(2985).then((data) => {
this.setState({geojsonData: JSON.parse(data[0].geojson)})
});
//and more
this.initData(4661).then((data) => {
this.setState({geojsonData6: JSON.parse(data[0].geojson)})
this.initMap()
});
}
render() {
<Map />
return <div id="map" style={style} />;
}
}
I think, I need to do something in render(), but I don't find actually the solution. Of course, when I do "marker.openPopup();" before the .isOpen(), the condition is true. But I want a action from the user?
Thanks !