diff --git a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-map-container/form-field-map-container.component.ts b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-map-container/form-field-map-container.component.ts index cfdce30104..be6a8b71a3 100644 --- a/libs/feature/editor/src/lib/components/record-form/form-field/form-field-map-container/form-field-map-container.component.ts +++ b/libs/feature/editor/src/lib/components/record-form/form-field/form-field-map-container/form-field-map-container.component.ts @@ -45,24 +45,18 @@ export class FormFieldMapContainerComponent implements OnChanges { }[] error = '' - viewExtent: Extent mapContext$: Observable = this.mapFacade.layers$.pipe( switchMap((layers) => - from(this.mapUtils.getLayerExtent(layers[layers.length - 1])).pipe( + from(this.mapUtils.getLayerExtent(layers[0])).pipe( catchError(() => { this.error = 'The layer has no extent' return of(undefined) }), map((extent) => { - this.viewExtent = this.mapUtils.getGeoJSONLayersExtent([ - this.viewExtent, - extent, - ]) - return { layers: [DEFAULT_BASELAYER_CONTEXT, ...layers], view: { - extent: this.viewExtent, + extent: extent, }, } as MapContextModel }) 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 dc688ee935..4c391160aa 100644 --- a/libs/feature/map/src/lib/utils/map-utils.service.ts +++ b/libs/feature/map/src/lib/utils/map-utils.service.ts @@ -166,13 +166,6 @@ export class MapUtilsService { return transformExtent(latLonExtent, 'EPSG:4326', 'EPSG:3857') } - getGeoJSONLayersExtent(extents: Extent[]) { - return extents.reduce( - (prev, curr) => (prev ? extend(prev, curr) : curr), - null as Extent - ) - } - async getWmsLayerExtent( layer: MapContextLayerWmsModel ): Promise {