diff --git a/src/modules/geoportal/components/map-viewer.tsx b/src/modules/geoportal/components/map-viewer.tsx index fb30876..6c4964b 100644 --- a/src/modules/geoportal/components/map-viewer.tsx +++ b/src/modules/geoportal/components/map-viewer.tsx @@ -487,10 +487,23 @@ export const MapViewer = forwardRef( paint: { "fill-color": "#3b82f6", "fill-opacity": 0.5 } }); map.addLayer({ id: LAYER_IDS.cladiriLine, type: "line", source: SOURCES.cladiri, "source-layer": SOURCES.cladiri, minzoom: 14, paint: { "line-color": "#1e3a5f", "line-width": 0.6 } }); - // Building cadastral_ref labels (e.g. C1, C2...) + // Building body labels — extract suffix after last dash (e.g. "291479-C1" → "C1") map.addLayer({ id: LAYER_IDS.cladiriLabel, type: "symbol", source: SOURCES.cladiri, "source-layer": SOURCES.cladiri, minzoom: 16, layout: { - "text-field": ["coalesce", ["get", "cadastral_ref"], ""], + "text-field": [ + "case", + ["has", "cadastral_ref"], + ["let", "ref", ["get", "cadastral_ref"], + ["let", "dashIdx", ["index-of", "-", ["var", "ref"]], + ["case", + [">=", ["var", "dashIdx"], 0], + ["slice", ["var", "ref"], ["+", ["var", "dashIdx"], 1]], + ["var", "ref"], + ], + ], + ], + "", + ], "text-font": ["Noto Sans Regular"], "text-size": 9, "text-anchor": "center", "text-allow-overlap": false, "text-max-width": 6,