Fix: Ensure proper map object is passed to ShowAddStationPopup

The ShowAddStationPopup component was failing to close popups because it was using an uninitialized 'map' object. This commit changes the reference from 'map' to 'initMap' at the point where ShowAddStationPopup is rendered. This ensures that the correct map instance is being used, resolving the TypeError related to undefined properties when attempting to close the popup.

This change is critical for maintaining the functionality of our map interactions, particularly in scenarios where dynamic components are rendered based on user actions.
This commit is contained in:
ISA
2024-05-03 07:20:51 +02:00
parent 5986de04dd
commit fb25f3a39d
4 changed files with 27 additions and 19 deletions

View File

@@ -415,7 +415,7 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
// Create a root container for the React component inside the popup
const root = ReactDOM.createRoot(container);
root.render(<ShowAddStationPopup map={map} latlng={e.latlng} />);
root.render(<ShowAddStationPopup map={initMap} latlng={e.latlng} />);
// Create and configure the popup
L.popup().setLatLng(e.latlng).setContent(container).openOn(initMap);