Robust MultiLine merge logic: appending new segments instead of overwriting
Deploy TrassenPlaner / deploy (push) Waiting to run
Details
Deploy TrassenPlaner / deploy (push) Waiting to run
Details
This commit is contained in:
parent
7d43513199
commit
05785f93cb
31
index.html
31
index.html
|
|
@ -1868,12 +1868,16 @@
|
||||||
e.layer.setStyle({ color: '#cca300', weight: 6 });
|
e.layer.setStyle({ color: '#cca300', weight: 6 });
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a new layer was created (via startPolyline), merge it into our existing layer
|
// If a new layer was created (via startPolyline or startNewPath), merge it into our existing layer
|
||||||
if (e.type === 'editable:created' && routeLayers[activeV.id] && e.layer !== routeLayers[activeV.id]) {
|
if (e.type === 'editable:created' && activeV && routeLayers[activeV.id] && e.layer !== routeLayers[activeV.id]) {
|
||||||
const newPoints = e.layer.getLatLngs();
|
const current = getNestedCoords(routeLayers[activeV.id].getLatLngs());
|
||||||
routeLayers[activeV.id].setLatLngs(newPoints);
|
const addition = e.layer.getLatLngs();
|
||||||
activeV.routes = newPoints;
|
const merged = [...current, addition];
|
||||||
map.removeLayer(e.layer); // We only want our primary layer
|
|
||||||
|
routeLayers[activeV.id].setLatLngs(merged);
|
||||||
|
activeV.routes = merged;
|
||||||
|
|
||||||
|
map.removeLayer(e.layer); // Clean up temp layer
|
||||||
routeLayers[activeV.id].enableEdit();
|
routeLayers[activeV.id].enableEdit();
|
||||||
} else if (routeLayers[activeV.id] && e.layer === routeLayers[activeV.id]) {
|
} else if (routeLayers[activeV.id] && e.layer === routeLayers[activeV.id]) {
|
||||||
activeV.routes = e.layer.getLatLngs();
|
activeV.routes = e.layer.getLatLngs();
|
||||||
|
|
@ -2190,22 +2194,11 @@
|
||||||
|
|
||||||
// --- Variant Management UI ---
|
// --- Variant Management UI ---
|
||||||
window.startNewPath = (id) => {
|
window.startNewPath = (id) => {
|
||||||
const layer = routeLayers[id];
|
if (map.editTools) {
|
||||||
if (layer) {
|
|
||||||
// Activate drawing state
|
|
||||||
state.isDrawing = true;
|
state.isDrawing = true;
|
||||||
state.isMeasuring = false;
|
state.isMeasuring = false;
|
||||||
updateToolCursors();
|
updateToolCursors();
|
||||||
|
map.editTools.startPolyline();
|
||||||
// Ensure edit mode is on
|
|
||||||
if (!layer.editor) layer.enableEdit();
|
|
||||||
|
|
||||||
// Trigger new path drawing
|
|
||||||
if (layer.editor) {
|
|
||||||
layer.editor.newPath();
|
|
||||||
} else {
|
|
||||||
console.error("Editor not found on layer", id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue