summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Koch <markus@notsyncing.net>2020-04-19 20:36:47 +0200
committerMarkus Koch <markus@notsyncing.net>2020-04-19 20:36:47 +0200
commit90161e098a03cf41343f4e335fbe4fdbe8766d05 (patch)
tree70ba447987d0ddc6c1659e43c61a2ba1c82731ba
parent4c7590a212c3900b6f6bf37d00afd6a0c72b84b3 (diff)
downloadlifomapserver-90161e098a03cf41343f4e335fbe4fdbe8766d05.tar.gz
lifomapserver-90161e098a03cf41343f4e335fbe4fdbe8766d05.tar.bz2
lifomapserver-90161e098a03cf41343f4e335fbe4fdbe8766d05.zip
editor: Add function to reset path
-rw-r--r--htdocs/streeteditor.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/htdocs/streeteditor.js b/htdocs/streeteditor.js
index a5e9e17..5d69d0b 100644
--- a/htdocs/streeteditor.js
+++ b/htdocs/streeteditor.js
@@ -57,6 +57,8 @@ if (editor_mode) {
for (var i = 0; i < coords.length; i++) {
coords[i] = [coords[i][1], coords[i][0]];
}
+ if (polyline)
+ polyline.remove(mymap);
polyline = L.polyline(coords).addTo(mymap);
// polyline.on('dragend', onDragEnd); // TODO: Doesn't work, see "workaround" below
polyline.enableEdit();
@@ -65,7 +67,6 @@ if (editor_mode) {
function editor_onHashChange() {
if (("#" + get_location_string()) != window.location.hash) {
- polyline.remove(mymap);
onLoad(0);
}
}
@@ -78,7 +79,6 @@ if (editor_mode) {
document.getElementById('mapid').classList.add("no-aa");
mymap.setMaxZoom(14);
mymap.off('click', onMapClick);
- onLoad();
function get_location_string() {
var latlngs = polyline.getLatLngs();
@@ -98,6 +98,10 @@ if (editor_mode) {
prompt("Copy this string back into the Wiki and wait for a few hours:", get_location_string());
}
+ function reset_path(e) {
+ onLoad(1);
+ }
+
L.EditControl = L.Control.extend({
options: {
position: 'topleft',
@@ -120,6 +124,15 @@ if (editor_mode) {
}
});
+ L.ResetPathControl = L.EditControl.extend({
+ options: {
+ position: 'topleft',
+ callback: reset_path,
+ title: 'Enter path coordinates',
+ html: '↺'
+ }
+ });
+
L.StartEditControl = L.EditControl.extend({
options: {
position: 'topleft',
@@ -139,5 +152,8 @@ if (editor_mode) {
});
mymap.addControl(new L.NewLineControl());
+ mymap.addControl(new L.ResetPathControl());
mymap.addControl(new L.StartEditControl());
+
+ onLoad();
}