diff --git a/libs/feature/map/src/lib/utils/map-utils.service.ts b/libs/feature/map/src/lib/utils/map-utils.service.ts index 2a73022bb8..969c30ee23 100644 --- a/libs/feature/map/src/lib/utils/map-utils.service.ts +++ b/libs/feature/map/src/lib/utils/map-utils.service.ts @@ -219,16 +219,19 @@ export class MapUtilsService { getRecordExtent(record: Partial): Extent { if (!('spatialExtents' in record)) { return null + } else if (record.spatialExtents.length > 0) { + // transform an array of geojson geometries into a bbox + const totalExtent = record.spatialExtents.reduce( + (prev, curr) => { + const geom = GEOJSON.readGeometry(curr.geometry) + return extend(prev, geom.getExtent()) + }, + [Infinity, Infinity, -Infinity, -Infinity] + ) + return transformExtent(totalExtent, 'EPSG:4326', 'EPSG:3857') + } else { + return null } - // transform an array of geojson geometries into a bbox - const totalExtent = record.spatialExtents.reduce( - (prev, curr) => { - const geom = GEOJSON.readGeometry(curr.geometry) - return extend(prev, geom.getExtent()) - }, - [Infinity, Infinity, -Infinity, -Infinity] - ) - return transformExtent(totalExtent, 'EPSG:4326', 'EPSG:3857') } }