Skip to content

Commit

Permalink
fix: make sure that newly created station is selected in main map
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Feb 10, 2023
1 parent 4665b3e commit 65d1737
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions _src/react-app/components/location/Station.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,20 @@ const Station = ({ mainMap, selectedStationName, selectStation }) => {
setCoordinates(config.emptyPoint);
setStreamLake('');
onPointDefSelected();
// TODO: clear selected stream or lake on map

mainMap.eachLayer((layer) => layer?.refresh && layer.refresh());
verifyMap.current.eachLayer((layer) => layer?.refresh && layer.refresh());

setTimeout(() => {
$(modal.current).modal('hide');
setShowSuccessMsg(false);
selectStation(
newStation.attributes[config.fieldNames.stations.NAME],
newStation.attributes[config.fieldNames.stations.STATION_ID]
);
// can't find a way to hook into when the layer is done refreshing...
setTimeout(() => {
selectStation(
newStation.attributes[config.fieldNames.stations.NAME],
newStation.attributes[config.fieldNames.stations.STATION_ID]
);
}, 1000);
}, 500);
};

Expand Down
4 changes: 2 additions & 2 deletions _src/react-app/components/location/VerifyMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ const MapHoister = ({ isMainMap, setMap, setStreamsLayer, setLakesLayer, selectS
const updateStyle = useCallback(
(geojson, layer) => {
if (!isMainMap) return;
console.log('updating styles');
console.log(`updating styles ${selectedStationId}`);
if (geojson.properties[config.fieldNames.stations.STATION_ID] === selectedStationId) {
layer.setIcon(selectedIcon);
} else {
layer.setIcon(defaultIcon);
}
},
[selectedStationId, isMainMap]
[isMainMap, selectedStationId]
);

useEffect(() => {
Expand Down

0 comments on commit 65d1737

Please sign in to comment.