Geomap: Fix data fit (#89247)

This commit is contained in:
Drew Slobodnjak 2024-06-14 10:09:47 -07:00 committed by GitHub
parent 79540a20b9
commit e53e6e7caa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,7 @@
import { createEmpty, extend, Extent } from 'ol/extent';
import LayerGroup from 'ol/layer/Group';
import VectorLayer from 'ol/layer/Vector';
import VectorImage from 'ol/layer/VectorImage';
import { MapLayerState } from '../types';
@ -11,12 +12,12 @@ export function getLayersExtent(
layer: string | undefined
): Extent {
return layers
.filter((l) => l.layer instanceof VectorLayer || l.layer instanceof LayerGroup)
.filter((l) => l.layer instanceof VectorLayer || l.layer instanceof LayerGroup || l.layer instanceof VectorImage)
.flatMap((ll) => {
const l = ll.layer;
if (l instanceof LayerGroup) {
return getLayerGroupExtent(l);
} else if (l instanceof VectorLayer) {
} else if (l instanceof VectorLayer || l instanceof VectorImage) {
if (allLayers) {
// Return everything from all layers
return [l.getSource().getExtent()] ?? [];