Check if there is a path to save, abort saving if file dialog is cancelled
This commit is contained in:
parent
eb4507d261
commit
906605feae
1 changed files with 8 additions and 1 deletions
|
@ -93,13 +93,13 @@ async function updateBrouter () {
|
||||||
markers[markers.length-1]._icon.classList.add("red");
|
markers[markers.length-1]._icon.classList.add("red");
|
||||||
markers[0]._icon.classList.add("green");
|
markers[0]._icon.classList.add("green");
|
||||||
}
|
}
|
||||||
|
geojsons = [];
|
||||||
if (markers.length < 2) {
|
if (markers.length < 2) {
|
||||||
if (geojson != undefined) {
|
if (geojson != undefined) {
|
||||||
map.removeLayer(geojson);
|
map.removeLayer(geojson);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
geojsons = [];
|
|
||||||
for (let i = 0; i < markers.length - 1 ; i++) {
|
for (let i = 0; i < markers.length - 1 ; i++) {
|
||||||
const marker1 = markers[i].getLatLng();
|
const marker1 = markers[i].getLatLng();
|
||||||
const marker2 = markers[i+1].getLatLng();
|
const marker2 = markers[i+1].getLatLng();
|
||||||
|
@ -154,7 +154,14 @@ async function pickDirectory(e){
|
||||||
document.getElementById("edit-mode").innerHTML = "save";
|
document.getElementById("edit-mode").innerHTML = "save";
|
||||||
editMode = true;
|
editMode = true;
|
||||||
} else {
|
} else {
|
||||||
|
if (geojsons.length < 1) {
|
||||||
|
alert("There is no path to save!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
const filename = window.prompt("Enter filename:", "test");
|
const filename = window.prompt("Enter filename:", "test");
|
||||||
|
if (filename === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const dat = {type: "FeatureCollection", features: geojsons};
|
const dat = {type: "FeatureCollection", features: geojsons};
|
||||||
const file = await dirHandle.getFileHandle(`${filename}.geojson`, {
|
const file = await dirHandle.getFileHandle(`${filename}.geojson`, {
|
||||||
create: true
|
create: true
|
||||||
|
|
Loading…
Add table
Reference in a new issue