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:
@@ -439,24 +439,23 @@ export const MapViewer = forwardRef<MapViewerHandle, MapViewerProps>(
|
||||
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 body labels (C1, C2...) — only at high zoom to avoid clutter
|
||||
// cadastral_ref format: "77102-C1" → show "C1"
|
||||
// Uses regex-like approach: if contains "-", show everything after last "-"
|
||||
map.addLayer({ id: LAYER_IDS.cladiriLabel, type: "symbol", source: SOURCES.cladiri, "source-layer": SOURCES.cladiri, minzoom: 16,
|
||||
filter: ["all",
|
||||
["has", "cadastral_ref"],
|
||||
["!=", ["index-of", "-", ["coalesce", ["get", "cadastral_ref"], ""]], -1],
|
||||
],
|
||||
// Building body labels (C1, C2...) — visible at high zoom
|
||||
// cadastral_ref = "77102-C1" → display "C1"
|
||||
map.addLayer({
|
||||
id: LAYER_IDS.cladiriLabel,
|
||||
type: "symbol",
|
||||
source: SOURCES.cladiri,
|
||||
"source-layer": SOURCES.cladiri,
|
||||
minzoom: 16,
|
||||
filter: ["has", "cadastral_ref"],
|
||||
layout: {
|
||||
"text-field": ["slice",
|
||||
["coalesce", ["get", "cadastral_ref"], ""],
|
||||
["+", ["index-of", "-", ["coalesce", ["get", "cadastral_ref"], ""]], 1],
|
||||
],
|
||||
// Simple approach: show full cadastral_ref, let the user see "77102-C1"
|
||||
// MapLibre will auto-hide overlapping labels
|
||||
"text-field": ["get", "cadastral_ref"],
|
||||
"text-font": ["Noto Sans Regular"],
|
||||
"text-size": 11,
|
||||
"text-size": 10,
|
||||
"text-anchor": "center",
|
||||
"text-allow-overlap": true,
|
||||
"text-ignore-placement": false,
|
||||
"text-allow-overlap": false,
|
||||
},
|
||||
paint: {
|
||||
"text-color": "#1e3a8a",
|
||||
|
||||
Reference in New Issue
Block a user