summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Koch <markus@notsyncing.net>2020-04-19 20:54:57 +0200
committerMarkus Koch <markus@notsyncing.net>2020-04-19 20:54:57 +0200
commitab2e50f851467363ff643a165b4f0e1d4dabbe5c (patch)
tree7cd92302571852a2e2da6ee510a0f87a08640bac
parent8ca10033f92924581b3713291bec90cb8b91cb4c (diff)
downloadlifomapserver-ab2e50f851467363ff643a165b4f0e1d4dabbe5c.tar.gz
lifomapserver-ab2e50f851467363ff643a165b4f0e1d4dabbe5c.tar.bz2
lifomapserver-ab2e50f851467363ff643a165b4f0e1d4dabbe5c.zip
editor: Add reverse backwards drawing mode and improve the reset handler
-rw-r--r--htdocs/streeteditor.js44
1 files changed, 33 insertions, 11 deletions
diff --git a/htdocs/streeteditor.js b/htdocs/streeteditor.js
index fea2b36..ced38ea 100644
--- a/htdocs/streeteditor.js
+++ b/htdocs/streeteditor.js
@@ -1,6 +1,7 @@
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
editor_mode = urlParams.has('editor');
+
if (editor_mode) {
var draw_layer;
var polyline;
@@ -13,13 +14,21 @@ if (editor_mode) {
return latlng;
}
- function start_editing(e) {
+ function start_editing(dir = 1) {
// TODO: Check whether we already are in edit mode
// TODO: Detect whether we are cloner to the tail or the head, and issue Fwd or Bwd accordingly
- if (polyline)
- polyline.editor.continueForward();
- else
+ if (polyline) {
+ if (dir)
+ polyline.editor.continueForward();
+ else
+ polyline.editor.continueBackward();
+ } else {
polyline = mymap.editTools.startPolyline();
+ }
+ }
+
+ function start_reverse_editing() {
+ start_editing(0);
}
function strToPoints(str) {
@@ -41,10 +50,6 @@ if (editor_mode) {
}
function onLoad(interactive = 1) {
- if (polyline) {
- polyline.remove(mymap);
- polyline = undefined;
- }
if (interactive) {
str = prompt("Instructions: \n" +
"* Click the scribble-icon in the top left to start or continue drawing.\n" +
@@ -52,10 +57,17 @@ if (editor_mode) {
"* Double click a waypoint to delete it.\n" +
"* Click save in the top right to get the new string.\n\n" +
"Enter existing waypoints in the following format: [x,y],[x,y]:", window.location.hash.slice(1));
+ if (!str)
+ return;
} else {
str = window.location.hash.slice(1);
}
+ if (polyline) {
+ polyline.remove(mymap);
+ polyline = undefined;
+ }
+
if (str) {
coords = strToPoints(str);
for (var i = 0; i < coords.length; i++) {
@@ -97,7 +109,7 @@ if (editor_mode) {
}
function show_location_string(e) {
- prompt("Copy this string back into the Wiki and wait for a few hours:", get_location_string());
+ prompt("Copy this string back into the Wiki and wait for the server to refresh the maps:", get_location_string());
}
function reset_path(e) {
@@ -131,7 +143,7 @@ if (editor_mode) {
position: 'topleft',
callback: reset_path,
title: 'Enter path coordinates',
- html: '↺'
+ html: '📂'
}
});
@@ -139,11 +151,20 @@ if (editor_mode) {
options: {
position: 'topleft',
callback: start_editing,
- title: 'Start editing',
+ title: 'Start editing (forward)',
html: '\\/\\'
}
});
+ L.StartReverseEditControl = L.EditControl.extend({
+ options: {
+ position: 'topleft',
+ callback: start_reverse_editing,
+ title: 'Start editing (backward)',
+ html: '↺'
+ }
+ });
+
L.NewLineControl = L.EditControl.extend({
options: {
position: 'topleft',
@@ -156,6 +177,7 @@ if (editor_mode) {
mymap.addControl(new L.NewLineControl());
mymap.addControl(new L.ResetPathControl());
mymap.addControl(new L.StartEditControl());
+ mymap.addControl(new L.StartReverseEditControl());
onLoad();
}