fix(geoportal): enrichment panel update + force-hide all layers + boundary filter
1. Enrichment: panel now updates immediately with returned data (was only showing message) 2. Layers: ALL data layers set to visibility:none immediately after creation, then only enabled ones are shown. Fixes cladiri appearing when only terenuri toggled. 3. OpenFreeMap boundaries: also filter by source-layer="boundary" (more reliable) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -76,7 +76,13 @@ export function FeatureInfoPanel({ feature, onClose }: FeatureInfoPanelProps) {
|
||||
});
|
||||
const d = await resp.json();
|
||||
if (resp.ok) {
|
||||
setEnrichMsg(d.message ?? "Enrichment pornit");
|
||||
// Update panel with enrichment data immediately
|
||||
if (d.enrichment && detail) {
|
||||
setDetail({ ...detail, enrichment: d.enrichment, enrichedAt: new Date().toISOString() });
|
||||
setEnrichMsg("");
|
||||
} else {
|
||||
setEnrichMsg(d.message ?? "Enrichment finalizat");
|
||||
}
|
||||
} else {
|
||||
setEnrichMsg(d.error ?? "Eroare la enrichment");
|
||||
}
|
||||
|
||||
@@ -362,14 +362,16 @@ export const MapViewer = forwardRef<MapViewerHandle, MapViewerProps>(
|
||||
map.on("load", () => {
|
||||
const m = resolvedMartinUrl;
|
||||
|
||||
// Hide OpenFreeMap's built-in layers we don't need
|
||||
// Hide OpenFreeMap's built-in boundary/admin layers
|
||||
for (const layer of map.getStyle().layers) {
|
||||
const id = layer.id.toLowerCase();
|
||||
if (
|
||||
id.includes("boundar") || id.includes("admin") ||
|
||||
(id.includes("border") && !id.includes("water")) ||
|
||||
id.includes("oneway") || id.includes("one-way") || id.includes("arrow")
|
||||
) {
|
||||
const id = layer.id;
|
||||
// Match common OpenMapTiles boundary layer naming patterns
|
||||
if (/boundar|admin|border(?!.*water)|oneway|arrow/i.test(id)) {
|
||||
try { map.setLayoutProperty(layer.id, "visibility", "none"); } catch { /* noop */ }
|
||||
}
|
||||
// Also hide by source-layer (more reliable)
|
||||
const sl = ("source-layer" in layer && typeof layer["source-layer"] === "string") ? layer["source-layer"] : "";
|
||||
if (sl === "boundary" || sl === "admin") {
|
||||
try { map.setLayoutProperty(layer.id, "visibility", "none"); } catch { /* noop */ }
|
||||
}
|
||||
}
|
||||
@@ -456,9 +458,15 @@ export const MapViewer = forwardRef<MapViewerHandle, MapViewerProps>(
|
||||
paint: { "line-color": "#f59e0b", "line-width": 2, "line-dasharray": [3, 2] },
|
||||
});
|
||||
|
||||
// Apply initial visibility — HIDE ALL by default, then show only enabled ones
|
||||
const allOff: Record<string, boolean> = { uats: false, terenuri: false, cladiri: false, administrativ: false };
|
||||
applyLayerVisibility(layerVisibility ? { ...allOff, ...layerVisibility } : allOff);
|
||||
// HIDE ALL data layers immediately after creation
|
||||
const allLayerIds = [
|
||||
...Object.values(LAYER_IDS).filter(id => !id.includes("draw") && !id.includes("selection")),
|
||||
];
|
||||
for (const lid of allLayerIds) {
|
||||
try { map.setLayoutProperty(lid, "visibility", "none"); } catch { /* noop */ }
|
||||
}
|
||||
// Then show only the ones that should be visible
|
||||
if (layerVisibility) applyLayerVisibility(layerVisibility);
|
||||
setMapReady(true);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user