refs #14 avoid strange behaviour of l.draw.plus; preserve alt and time when cut
parent
f140907740
commit
9b8a127298
|
@ -50,7 +50,7 @@ L.Control.Draw.Plus = L.Control.Draw.extend({
|
||||||
|
|
||||||
// Add new features to the editor
|
// Add new features to the editor
|
||||||
map.on('draw:created', function(e) {
|
map.on('draw:created', function(e) {
|
||||||
this.addLayer(e.layer);
|
//this.addLayer(e.layer);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// Remove deleted features from the editor
|
// Remove deleted features from the editor
|
||||||
|
@ -74,8 +74,8 @@ L.Control.Draw.Plus = L.Control.Draw.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean features & rewrite json field
|
// Clean features & rewrite json field
|
||||||
map.on('draw:created draw:editvertex', this._optimSavGeom, this); // When something has changed
|
//map.on('draw:created draw:editvertex', this._optimSavGeom, this); // When something has changed
|
||||||
this._optimSavGeom(false); // At the init
|
//this._optimSavGeom(false); // At the init
|
||||||
|
|
||||||
return L.Control.Draw.prototype.onAdd.call(this, map);
|
return L.Control.Draw.prototype.onAdd.call(this, map);
|
||||||
},
|
},
|
||||||
|
@ -138,13 +138,13 @@ L.Control.Draw.Plus = L.Control.Draw.extend({
|
||||||
|
|
||||||
layer.snapediting.addGuideLayer(this.snapLayers);
|
layer.snapediting.addGuideLayer(this.snapLayers);
|
||||||
layer.snapediting.enable();
|
layer.snapediting.enable();
|
||||||
this._optimSavGeom(); // Optimize & write full json on output element
|
//this._optimSavGeom(); // Optimize & write full json on output element
|
||||||
|
|
||||||
// Close enables edit toolbar handlers & save changes
|
// Close enables edit toolbar handlers & save changes
|
||||||
layer.on('deleted', function() {
|
layer.on('deleted', function() {
|
||||||
for (m in this._toolbars['edit']._modes)
|
for (m in this._toolbars['edit']._modes)
|
||||||
this._toolbars['edit']._modes[m].handler.disable();
|
this._toolbars['edit']._modes[m].handler.disable();
|
||||||
this._optimSavGeom();
|
//this._optimSavGeom();
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -223,10 +223,26 @@ L.Edit.PolyVerticesEdit.prototype.options.touchIcon.options.iconSize = new L.Poi
|
||||||
L.Edit.PolyVerticesEdit.include({
|
L.Edit.PolyVerticesEdit.include({
|
||||||
_cut: function(e) {
|
_cut: function(e) {
|
||||||
// Split markers on each side of the cut
|
// Split markers on each side of the cut
|
||||||
|
var alt;
|
||||||
var found = 0,
|
var found = 0,
|
||||||
lls = [[],[]];
|
lls = [[],[]],
|
||||||
|
times = [[],[]];
|
||||||
for (m in this._markers) {
|
for (m in this._markers) {
|
||||||
|
if (this._markers[m]._latlng.alt) {
|
||||||
|
lls[found].push(
|
||||||
|
[
|
||||||
|
this._markers[m]._latlng.lat,
|
||||||
|
this._markers[m]._latlng.lng,
|
||||||
|
this._markers[m]._latlng.alt
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
lls[found].push(this._markers[m]._latlng);
|
lls[found].push(this._markers[m]._latlng);
|
||||||
|
}
|
||||||
|
if (this._markers[m]._latlng.time) {
|
||||||
|
times[found].push(this._markers[m]._latlng.time);
|
||||||
|
}
|
||||||
if (this._markers[m]._middleRight && this._markers[m]._middleRight._leaflet_id == e.target._leaflet_id)
|
if (this._markers[m]._middleRight && this._markers[m]._middleRight._leaflet_id == e.target._leaflet_id)
|
||||||
found = 1; // We find the cut point
|
found = 1; // We find the cut point
|
||||||
}
|
}
|
||||||
|
@ -242,11 +258,21 @@ L.Edit.PolyVerticesEdit.include({
|
||||||
|
|
||||||
// This is a polyline
|
// This is a polyline
|
||||||
else
|
else
|
||||||
for (f in lls)
|
for (f in lls) {
|
||||||
if (lls[f].length > 1)
|
if (lls[f].length > 1) {
|
||||||
|
var p = new L.Polyline(lls[f]);
|
||||||
|
if (times[f].length === p._latlngs.length) {
|
||||||
|
for (var i=0; i<times[f].length; i++) {
|
||||||
|
if (times[f][i]) {
|
||||||
|
p._latlngs[i].time = times[f][i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
this._map.fire('draw:created', { // Create a new Polyline with the splited summits if any
|
this._map.fire('draw:created', { // Create a new Polyline with the splited summits if any
|
||||||
layer: new L.Polyline(lls[f])
|
layer: p
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Optimize
|
// Optimize
|
||||||
this._map.fire('draw:editvertex');
|
this._map.fire('draw:editvertex');
|
||||||
|
|
|
@ -164,13 +164,13 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var hoverStyle = {
|
var hoverStyle = {
|
||||||
weight: 12,
|
weight: 10,
|
||||||
opacity: 0.7,
|
opacity: 0.7,
|
||||||
color: 'black'
|
color: 'black'
|
||||||
};
|
};
|
||||||
var defaultStyle = {
|
var defaultStyle = {
|
||||||
opacity: 0.9,
|
opacity: 0.9,
|
||||||
color: '#f357a1',
|
color: '#1196DA',
|
||||||
weight: 7
|
weight: 7
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -640,7 +640,6 @@
|
||||||
var comment = gpxedit.layersData[id].comment;
|
var comment = gpxedit.layersData[id].comment;
|
||||||
var description = gpxedit.layersData[id].description;
|
var description = gpxedit.layersData[id].description;
|
||||||
var time = gpxedit.layersData[id].time;
|
var time = gpxedit.layersData[id].time;
|
||||||
console.log('aa '+layer.type);
|
|
||||||
if (layer.type === 'marker') {
|
if (layer.type === 'marker') {
|
||||||
var symbol = gpxedit.layersData[id].symbol;
|
var symbol = gpxedit.layersData[id].symbol;
|
||||||
lat = layer._latlng.lat;
|
lat = layer._latlng.lat;
|
||||||
|
@ -774,10 +773,8 @@
|
||||||
function drawLine(latlngs, name, desc, cmt, gpxtype, times) {
|
function drawLine(latlngs, name, desc, cmt, gpxtype, times) {
|
||||||
var wst = $('#markerstyleselect').val();
|
var wst = $('#markerstyleselect').val();
|
||||||
var tst = $('#tooltipstyleselect').val();
|
var tst = $('#tooltipstyleselect').val();
|
||||||
var p = L.polyline(latlngs, {
|
var p = L.polyline(latlngs);
|
||||||
color: '#f357a1',
|
p.setStyle(defaultStyle);
|
||||||
weight: 7
|
|
||||||
});
|
|
||||||
if (times.length === p._latlngs.length) {
|
if (times.length === p._latlngs.length) {
|
||||||
for (var i=0; i<times.length; i++) {
|
for (var i=0; i<times.length; i++) {
|
||||||
if (times[i]) {
|
if (times[i]) {
|
||||||
|
|
Loading…
Reference in New Issue