diff --git a/index.html b/index.html
index 9985f05..8d8baab 100644
--- a/index.html
+++ b/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();
}
};