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();
|
const d = await resp.json();
|
||||||
if (resp.ok) {
|
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 {
|
} else {
|
||||||
setEnrichMsg(d.error ?? "Eroare la enrichment");
|
setEnrichMsg(d.error ?? "Eroare la enrichment");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,14 +362,16 @@ export const MapViewer = forwardRef<MapViewerHandle, MapViewerProps>(
|
|||||||
map.on("load", () => {
|
map.on("load", () => {
|
||||||
const m = resolvedMartinUrl;
|
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) {
|
for (const layer of map.getStyle().layers) {
|
||||||
const id = layer.id.toLowerCase();
|
const id = layer.id;
|
||||||
if (
|
// Match common OpenMapTiles boundary layer naming patterns
|
||||||
id.includes("boundar") || id.includes("admin") ||
|
if (/boundar|admin|border(?!.*water)|oneway|arrow/i.test(id)) {
|
||||||
(id.includes("border") && !id.includes("water")) ||
|
try { map.setLayoutProperty(layer.id, "visibility", "none"); } catch { /* noop */ }
|
||||||
id.includes("oneway") || id.includes("one-way") || id.includes("arrow")
|
}
|
||||||
) {
|
// 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 */ }
|
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] },
|
paint: { "line-color": "#f59e0b", "line-width": 2, "line-dasharray": [3, 2] },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Apply initial visibility — HIDE ALL by default, then show only enabled ones
|
// HIDE ALL data layers immediately after creation
|
||||||
const allOff: Record<string, boolean> = { uats: false, terenuri: false, cladiri: false, administrativ: false };
|
const allLayerIds = [
|
||||||
applyLayerVisibility(layerVisibility ? { ...allOff, ...layerVisibility } : allOff);
|
...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);
|
setMapReady(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user