Compare commits
2 Commits
5b5ce97a1a
...
777905e7f1
Author | SHA1 | Date | |
---|---|---|---|
777905e7f1 | |||
035eb5a992 |
@ -62,6 +62,9 @@ var style_outlines = {
|
|||||||
fillOpacity: 0.5
|
fillOpacity: 0.5
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var style_streets = {
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Projection fix from: https://gis.stackexchange.com/questions/200865/leaflet-crs-simple-custom-scale
|
// Projection fix from: https://gis.stackexchange.com/questions/200865/leaflet-crs-simple-custom-scale
|
||||||
var factorx = 1 / 256 * 4;
|
var factorx = 1 / 256 * 4;
|
||||||
|
@ -9,6 +9,14 @@ if (editor_mode) {
|
|||||||
var polyline;
|
var polyline;
|
||||||
|
|
||||||
var edit_active = 0;
|
var edit_active = 0;
|
||||||
|
|
||||||
|
var editor_style = {
|
||||||
|
radius: 8,
|
||||||
|
fillColor: "#00ff00",
|
||||||
|
color: "red",
|
||||||
|
opacity: 1.0,
|
||||||
|
fillOpacity: 0.5
|
||||||
|
};
|
||||||
|
|
||||||
function start_editing(dir = 1) {
|
function start_editing(dir = 1) {
|
||||||
// TODO: Check whether we already are in edit mode
|
// TODO: Check whether we already are in edit mode
|
||||||
@ -73,9 +81,9 @@ if (editor_mode) {
|
|||||||
coords[i] = [coords[i][1], coords[i][0]];
|
coords[i] = [coords[i][1], coords[i][0]];
|
||||||
}
|
}
|
||||||
if (editor_mode_polygon)
|
if (editor_mode_polygon)
|
||||||
polyline = L.polygon([coords]).addTo(mymap);
|
polyline = L.polygon([coords], editor_style).addTo(mymap);
|
||||||
else
|
else
|
||||||
polyline = L.polyline(coords).addTo(mymap);
|
polyline = L.polyline(coords, editor_style).addTo(mymap);
|
||||||
// polyline.on('dragend', onDragEnd); // TODO: Doesn't work, see "workaround" below
|
// polyline.on('dragend', onDragEnd); // TODO: Doesn't work, see "workaround" below
|
||||||
polyline.enableEdit();
|
polyline.enableEdit();
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
@ -95,9 +103,17 @@ if (editor_mode) {
|
|||||||
window.addEventListener("hashchange", editor_onHashChange, false);
|
window.addEventListener("hashchange", editor_onHashChange, false);
|
||||||
window.addEventListener("mouseup", onDragEnd, false); // Workaround as polyline.on(dragend, ) doesn't seem to work
|
window.addEventListener("mouseup", onDragEnd, false); // Workaround as polyline.on(dragend, ) doesn't seem to work
|
||||||
|
|
||||||
|
function onMapKeydown(e) {
|
||||||
|
if (e.originalEvent.key == "Escape") {
|
||||||
|
if (polyline)
|
||||||
|
polyline.editor.cancelDrawing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Configure map for better editing
|
// Configure map for better editing
|
||||||
mymap.setMaxZoom(14);
|
mymap.setMaxZoom(14);
|
||||||
mymap.off('click', onMapClick);
|
mymap.off('click', onMapClick);
|
||||||
|
mymap.on('keydown', onMapKeydown);
|
||||||
|
|
||||||
function get_location_string() {
|
function get_location_string() {
|
||||||
var latlngs;
|
var latlngs;
|
||||||
|
Loading…
Reference in New Issue
Block a user