Skip to content

Commit

Permalink
restore reset/clear map funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinElms committed Feb 3, 2025
1 parent 186ccec commit 10a5a5d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion oceannavigator/frontend/src/components/DrawingTools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function DrawingTools(props) {
};

const handleClear = () => {
props.action("clearPoints");
props.action("clearFeatures");
};

const handleUndo = () => {
Expand Down
8 changes: 5 additions & 3 deletions oceannavigator/frontend/src/components/OceanNavigator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,15 @@ function OceanNavigator(props) {
case "undoMapFeature":
mapRef.current.undoFeature();
break;
case "clearPoints":
// TODO: update
setVectorId(null);
case "clearFeatures":
mapRef.current.removeFeatures("all")
break;
case "resetMap":
// TODO: update
mapRef.current.resetMap();
if (uiSettings.showDrawingTools) {
mapRef.current.startDrawing();
}
break;
case "addPoints":
// TODO: remove
Expand Down
14 changes: 8 additions & 6 deletions oceannavigator/frontend/src/components/map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,14 @@ const Map = forwardRef((props, ref) => {
};

const removeFeatures = (featureIds) => {
let toRemove = featureIds.map((id) => {
return vectorSource.getFeatureById(id);
});
let toRemove;
if (featureIds === "all") {
toRemove = vectorSource.getFeatures();
} else {
toRemove = featureIds.map((id) => {
return vectorSource.getFeatureById(id);
});
}
vectorSource.removeFeatures(toRemove);
};

Expand Down Expand Up @@ -698,9 +703,6 @@ const Map = forwardRef((props, ref) => {
if (props.compareDatasets) {
removeMapInteractions(map1, "all");
}
// TODO: refactor
props.updateState(["vectorType", "vectorId", "names"], ["point", null, []]);
props.action("clearPoints");

let newVectorSource = new VectorSource({
features: [],
Expand Down

0 comments on commit 10a5a5d

Please sign in to comment.