summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Koch <markus@notsyncing.net>2020-04-20 18:51:10 +0200
committerMarkus Koch <markus@notsyncing.net>2020-04-20 18:51:10 +0200
commit3cb30788200babf53b0718283d5de61e3460f15e (patch)
treeee4e57a7e2a3220083ffae31a9c62d8406a38e34
parentae47583e2d0e5ef546d6869f2ff5104f7911d68f (diff)
downloadlifomapserver-3cb30788200babf53b0718283d5de61e3460f15e.tar.gz
lifomapserver-3cb30788200babf53b0718283d5de61e3460f15e.tar.bz2
lifomapserver-3cb30788200babf53b0718283d5de61e3460f15e.zip
Add editor mode for polygons
-rw-r--r--htdocs/streeteditor.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/htdocs/streeteditor.js b/htdocs/streeteditor.js
index 2d9f074..76d5732 100644
--- a/htdocs/streeteditor.js
+++ b/htdocs/streeteditor.js
@@ -3,6 +3,8 @@ const urlParams = new URLSearchParams(queryString);
editor_mode = urlParams.has('editor');
if (editor_mode) {
+ var editor_mode_polygon = urlParams.has('polygon');
+
var draw_layer;
var polyline;
@@ -23,7 +25,10 @@ if (editor_mode) {
else
polyline.editor.continueBackward();
} else {
- polyline = mymap.editTools.startPolyline();
+ if (editor_mode_polygon)
+ polyline = mymap.editTools.startPolygon();
+ else
+ polyline = mymap.editTools.startPolyline();
}
}
@@ -73,7 +78,10 @@ if (editor_mode) {
for (var i = 0; i < coords.length; i++) {
coords[i] = [coords[i][1], coords[i][0]];
}
- polyline = L.polyline(coords).addTo(mymap);
+ if (editor_mode_polygon)
+ polyline = L.polygon([coords]).addTo(mymap);
+ else
+ polyline = L.polyline(coords).addTo(mymap);
// polyline.on('dragend', onDragEnd); // TODO: Doesn't work, see "workaround" below
polyline.enableEdit();
if (interactive) {
@@ -98,7 +106,11 @@ if (editor_mode) {
mymap.off('click', onMapClick);
function get_location_string() {
- var latlngs = polyline.getLatLngs();
+ var latlngs;
+ if (editor_mode_polygon)
+ latlngs = polyline.getLatLngs()[0];
+ else
+ latlngs = polyline.getLatLngs();
var str = "";
for (var i = 0; i < latlngs.length; i++) {