diff --git a/webapp/packages/plugin-gis-viewer/src/LeafletMap.tsx b/webapp/packages/plugin-gis-viewer/src/LeafletMap.tsx index 04ee532e77..4fccdbd03c 100644 --- a/webapp/packages/plugin-gis-viewer/src/LeafletMap.tsx +++ b/webapp/packages/plugin-gis-viewer/src/LeafletMap.tsx @@ -141,18 +141,12 @@ export const LeafletMap: React.FC = function LeafletMap({ geoJSON, getAss }, [getAssociatedValues]); useEffect(() => { - if (geoJSONLayerRef) { + if (geoJSONLayerRef && mapRef) { geoJSONLayerRef.clearLayers(); for (let i = 0; i < geoJSON.length; i++) { geoJSONLayerRef.addData(geoJSON[i]); } - } - }, [geoJSON, geoJSONLayerRef]); - - useEffect(() => { - if (mapRef && geoJSONLayerRef) { - mapRef.invalidateSize(); const bounds = geoJSONLayerRef.getBounds(); @@ -172,7 +166,13 @@ export const LeafletMap: React.FC = function LeafletMap({ geoJSON, getAss mapRef.fitBounds(bounds); } } - }, [splitContext.isResizing, splitContext.mode, mapRef, geoJSONLayerRef, crs, geoJSON]); + }, [geoJSON, geoJSONLayerRef, crs, mapRef]); + + useEffect(() => { + if (mapRef) { + mapRef.invalidateSize(); + } + }, [splitContext.isResizing, splitContext.mode, mapRef]); return styled(styles)(