Add editor mode for polygons
This commit is contained in:
parent
ae47583e2d
commit
3cb3078820
@ -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,6 +25,9 @@ if (editor_mode) {
|
||||
else
|
||||
polyline.editor.continueBackward();
|
||||
} else {
|
||||
if (editor_mode_polygon)
|
||||
polyline = mymap.editTools.startPolygon();
|
||||
else
|
||||
polyline = mymap.editTools.startPolyline();
|
||||
}
|
||||
}
|
||||
@ -73,6 +78,9 @@ if (editor_mode) {
|
||||
for (var i = 0; i < coords.length; i++) {
|
||||
coords[i] = [coords[i][1], coords[i][0]];
|
||||
}
|
||||
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();
|
||||
@ -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++) {
|
||||
|
Loading…
Reference in New Issue
Block a user