Fix variant mapping to preserve UI layer references
Deploy TrassenPlaner / deploy (push) Waiting to run Details

This commit is contained in:
Johannes Baumeister 2026-04-20 10:26:20 +02:00
parent c85f3eae82
commit f7227421a1
1 changed files with 4 additions and 4 deletions

View File

@ -2826,18 +2826,18 @@
const slot = state.variants.find(lv => lv.name === varName); const slot = state.variants.find(lv => lv.name === varName);
if (slot && f.geometry && f.geometry.coordinates) { if (slot && f.geometry && f.geometry.coordinates) {
slot.id = f.id || p.fid || p.id || p._id || slot.id; // Store the database ID separately so we don't break UI layer references
slot.dbId = f.id || p.fid || p.id || p._id;
// Handle potential nested coordinate arrays from different GIS exports // Handle potential nested coordinate arrays
let coords = f.geometry.coordinates; let coords = f.geometry.coordinates;
if (f.geometry.type === "LineString") { if (f.geometry.type === "LineString") {
slot.routes = coords.map(c => ({ lat: c[1], lng: c[0] })); slot.routes = coords.map(c => ({ lat: c[1], lng: c[0] }));
} else if (f.geometry.type === "MultiLineString") { } else if (f.geometry.type === "MultiLineString") {
// Take the first segment of a MultiLineString if it's imported that way
slot.routes = coords[0].map(c => ({ lat: c[1], lng: c[0] })); slot.routes = coords[0].map(c => ({ lat: c[1], lng: c[0] }));
} }
// Re-sync the polyline layer if it exists // Use the original UI ID to find the map layer
if (routeLayers[slot.id]) { if (routeLayers[slot.id]) {
routeLayers[slot.id].setLatLngs(slot.routes); routeLayers[slot.id].setLatLngs(slot.routes);
} }