Skip to content

Commit

Permalink
Reset state when importing another area
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Dec 1, 2022
1 parent a7f35f0 commit 1cbf32f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions street-explorer/www/js/lane_editor.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { downloadGeneratedFile } from "./files.js";
import {
makeIntersectionMarkingsLayer,
makeLaneMarkingsLayer,
lanePolygonStyle,
makePlainGeoJsonLayer,
lanePolygonStyle,
} from "./layers.js";
import { setupLeafletMap } from "./leaflet.js";
import init, { JsStreetNetwork } from "./osm2streets-js/osm2streets_js.js";
Expand All @@ -18,7 +19,6 @@ export class LaneEditor {
this.currentWaysLayer = null;
this.editedWays = new Set();

// Wire up the import button
const importButton = document.getElementById("import-view");
importButton.onclick = async () => {
if (this.map.getZoom() < 15) {
Expand All @@ -35,6 +35,16 @@ export class LaneEditor {
}

async importView(importButton) {
// Reset state
this.currentWay = null;
if (this.currentWaysLayer) {
this.currentWaysLayer.remove();
}
this.currentWaysLayer = null;
this.editedWays = new Set();
document.getElementById("edits-list").innerText = "0 edits";
document.getElementById("tags").innerHTML = "";

// Grab OSM XML from Overpass
// (Sadly toBBoxString doesn't seem to match the order for Overpass)
const b = app.map.getBounds();
Expand Down Expand Up @@ -115,6 +125,11 @@ export class LaneEditor {
this.layers.push(
makeLaneMarkingsLayer(this.network.toLaneMarkingsGeojson())
);
this.layers.push(
makeIntersectionMarkingsLayer(
this.network.toIntersectionMarkingsGeojson()
)
);

for (const layer of this.layers) {
layer.addTo(this.map);
Expand Down

0 comments on commit 1cbf32f

Please sign in to comment.