fix(geoportal): simplify building labels — show full cadastral_ref

Previous index-of/slice expression wasn't rendering. Simplified to
just show the full cadastral_ref (e.g. "77102-C1") as-is. MapLibre
auto-hides overlapping labels. This is a diagnostic step to verify
the tile property is accessible.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-27 07:57:45 +02:00
parent 6c5aa61f09
commit 49a239006d
+14 -15
View File
@@ -439,24 +439,23 @@ export const MapViewer = forwardRef<MapViewerHandle, MapViewerProps>(
paint: { "fill-color": "#3b82f6", "fill-opacity": 0.5 } }); 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, 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 } }); paint: { "line-color": "#1e3a5f", "line-width": 0.6 } });
// Building body labels (C1, C2...) — only at high zoom to avoid clutter // Building body labels (C1, C2...) — visible at high zoom
// cadastral_ref format: "77102-C1" → show "C1" // cadastral_ref = "77102-C1" → display "C1"
// Uses regex-like approach: if contains "-", show everything after last "-" map.addLayer({
map.addLayer({ id: LAYER_IDS.cladiriLabel, type: "symbol", source: SOURCES.cladiri, "source-layer": SOURCES.cladiri, minzoom: 16, id: LAYER_IDS.cladiriLabel,
filter: ["all", type: "symbol",
["has", "cadastral_ref"], source: SOURCES.cladiri,
["!=", ["index-of", "-", ["coalesce", ["get", "cadastral_ref"], ""]], -1], "source-layer": SOURCES.cladiri,
], minzoom: 16,
filter: ["has", "cadastral_ref"],
layout: { layout: {
"text-field": ["slice", // Simple approach: show full cadastral_ref, let the user see "77102-C1"
["coalesce", ["get", "cadastral_ref"], ""], // MapLibre will auto-hide overlapping labels
["+", ["index-of", "-", ["coalesce", ["get", "cadastral_ref"], ""]], 1], "text-field": ["get", "cadastral_ref"],
],
"text-font": ["Noto Sans Regular"], "text-font": ["Noto Sans Regular"],
"text-size": 11, "text-size": 10,
"text-anchor": "center", "text-anchor": "center",
"text-allow-overlap": true, "text-allow-overlap": false,
"text-ignore-placement": false,
}, },
paint: { paint: {
"text-color": "#1e3a8a", "text-color": "#1e3a8a",