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 });
|
||||
}
|
||||
|
||||
// If a new layer was created (via startPolyline), merge it into our existing layer
|
||||
if (e.type === 'editable:created' && routeLayers[activeV.id] && e.layer !== routeLayers[activeV.id]) {
|
||||
const newPoints = e.layer.getLatLngs();
|
||||
routeLayers[activeV.id].setLatLngs(newPoints);
|
||||
activeV.routes = newPoints;
|
||||
map.removeLayer(e.layer); // We only want our primary layer
|
||||
// If a new layer was created (via startPolyline or startNewPath), merge it into our existing layer
|
||||
if (e.type === 'editable:created' && activeV && routeLayers[activeV.id] && e.layer !== routeLayers[activeV.id]) {
|
||||
const current = getNestedCoords(routeLayers[activeV.id].getLatLngs());
|
||||
const addition = e.layer.getLatLngs();
|
||||
const merged = [...current, addition];
|
||||
|
||||
routeLayers[activeV.id].setLatLngs(merged);
|
||||
activeV.routes = merged;
|
||||
|
||||
map.removeLayer(e.layer); // Clean up temp layer
|
||||
routeLayers[activeV.id].enableEdit();
|
||||
} else if (routeLayers[activeV.id] && e.layer === routeLayers[activeV.id]) {
|
||||
activeV.routes = e.layer.getLatLngs();
|
||||
|
|
@ -2190,22 +2194,11 @@
|
|||
|
||||
// --- Variant Management UI ---
|
||||
window.startNewPath = (id) => {
|
||||
const layer = routeLayers[id];
|
||||
if (layer) {
|
||||
// Activate drawing state
|
||||
if (map.editTools) {
|
||||
state.isDrawing = true;
|
||||
state.isMeasuring = false;
|
||||
updateToolCursors();
|
||||
|
||||
// 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);
|
||||
}
|
||||
map.editTools.startPolyline();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue