refs #14 splitted lines get attributes from original line; fix style when split

merge-requests/1/head
Julien Veyssier 2017-05-09 03:00:09 +02:00
parent 9b8a127298
commit 0940377fa2
2 changed files with 41 additions and 10 deletions

View File

@ -261,6 +261,7 @@ L.Edit.PolyVerticesEdit.include({
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]); var p = new L.Polyline(lls[f]);
p.gpxedit_id = this._poly.gpxedit_id;
if (times[f].length === p._latlngs.length) { if (times[f].length === p._latlngs.length) {
for (var i=0; i<times[f].length; i++) { for (var i=0; i<times[f].length; i++) {
if (times[f][i]) { if (times[f][i]) {
@ -269,7 +270,8 @@ L.Edit.PolyVerticesEdit.include({
} }
} }
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: p layer: p,
layerType: 'polyline'
}); });
} }
} }

View File

@ -461,15 +461,18 @@
// it generates the popup content and initializes the layer's data // it generates the popup content and initializes the layer's data
// it returns the layer in case we want to set the layer's data manually (when loading a gpx) // it returns the layer in case we want to set the layer's data manually (when loading a gpx)
function onCreated(type, layer) { function onCreated(type, layer) {
var tst = $('#tooltipstyleselect').val();
var popupTitle; var popupTitle;
var layerType; var layerType;
if (type === 'polyline' || type === 'track') { if (type === 'polyline' || type === 'track') {
popupTitle = t('gpxedit', 'Track'); popupTitle = t('gpxedit', 'Track');
layerType = 'track'; layerType = 'track';
layer.setStyle(defaultStyle);
} }
else if (type === 'route') { else if (type === 'route') {
popupTitle = t('gpxedit', 'Route'); popupTitle = t('gpxedit', 'Route');
layerType = 'route'; layerType = 'route';
layer.setStyle(defaultStyle);
} }
else if (type === 'marker') { else if (type === 'marker') {
popupTitle = t('gpxedit', 'Waypoint'); popupTitle = t('gpxedit', 'Waypoint');
@ -514,8 +517,32 @@
}); });
} }
layer.gpxedit_id = gpxedit.id; // get properties of the splited line
layer.type = layerType; if (layer.hasOwnProperty('gpxedit_id')) {
gpxedit.layersData[gpxedit.id] = {
name: gpxedit.layersData[layer.gpxedit_id].name,
description: gpxedit.layersData[layer.gpxedit_id].description,
comment: gpxedit.layersData[layer.gpxedit_id].comment,
symbol: gpxedit.layersData[layer.gpxedit_id].symbol,
time: gpxedit.layersData[layer.gpxedit_id].time,
layer: layer
};
if (gpxedit.layersData[layer.gpxedit_id].name !== '') {
if (tst === 'p') {
layer.bindTooltip(
gpxedit.layersData[layer.gpxedit_id].name,
{permanent: true}
);
}
else{
layer.bindTooltip(
gpxedit.layersData[layer.gpxedit_id].name,
{sticky: true}
);
}
}
}
else {
gpxedit.layersData[gpxedit.id] = { gpxedit.layersData[gpxedit.id] = {
name: '', name: '',
description: '', description: '',
@ -524,6 +551,9 @@
time: '', time: '',
layer: layer layer: layer
}; };
}
layer.gpxedit_id = gpxedit.id;
layer.type = layerType;
gpxedit.drawControl.editLayers.addLayer(layer); gpxedit.drawControl.editLayers.addLayer(layer);
gpxedit.id++; gpxedit.id++;
return layer; return layer;
@ -774,7 +804,6 @@
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);
p.setStyle(defaultStyle);
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]) {