diff --git a/libs/feature/map/src/lib/map-context/map-context.model.ts b/libs/feature/map/src/lib/map-context/map-context.model.ts index 63d7ed833d..0b138243c8 100644 --- a/libs/feature/map/src/lib/map-context/map-context.model.ts +++ b/libs/feature/map/src/lib/map-context/map-context.model.ts @@ -20,18 +20,21 @@ export interface MapContextLayerWmsModel { type: 'wms' url: string name: string + attributions?: string } export interface MapContextLayerWmtsModel { type: 'wmts' url: string name: string + attributions?: string } interface MapContextLayerWfsModel { type: 'wfs' url: string name: string + attributions?: string } export interface MapContextLayerOgcapiModel { @@ -39,11 +42,13 @@ export interface MapContextLayerOgcapiModel { url: string name: string layerType: 'feature' | 'vectorTiles' | 'mapTiles' | 'record' + attributions?: string } interface LayerXyzModel { type: 'xyz' name?: string + attributions?: string } interface LayerXyzModelWithUrl extends LayerXyzModel { url: string @@ -59,6 +64,7 @@ export type MapContextLayerXyzModel = interface LayerGeojson { type: 'geojson' + attributions?: string } interface LayerGeojsonWithUrl extends LayerGeojson { url: string diff --git a/libs/feature/map/src/lib/map-context/map-context.service.ts b/libs/feature/map/src/lib/map-context/map-context.service.ts index 8b63e20b48..a2df1a065f 100644 --- a/libs/feature/map/src/lib/map-context/map-context.service.ts +++ b/libs/feature/map/src/lib/map-context/map-context.service.ts @@ -37,6 +37,7 @@ export const DEFAULT_BASELAYER_CONTEXT: MapContextLayerXyzModel = { `https://b.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png`, `https://c.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png`, ], + attributions: `© OpenStreetMap contributors, © Carto`, } export const DEFAULT_VIEW: MapContextViewModel = { @@ -87,12 +88,14 @@ export class MapContextService { source: new OGCVectorTile({ url: layerModel.url, format: new MVT(), + attributions: layerModel.attributions, }), }) } else if (layerModel.layerType === 'mapTiles') { return new TileLayer({ source: new OGCMapTile({ url: layerModel.url, + attributions: layerModel.attributions, }), }) } else { @@ -100,6 +103,7 @@ export class MapContextService { source: new VectorSource({ format: new GeoJSON(), url: layerModel.url, + attributions: layerModel.attributions, }), style, }) @@ -109,6 +113,7 @@ export class MapContextService { source: new XYZ({ url: 'url' in layerModel ? layerModel.url : undefined, urls: 'urls' in layerModel ? layerModel.urls : undefined, + attributions: layerModel.attributions, }), }) case MapContextLayerTypeEnum.WMS: @@ -117,6 +122,7 @@ export class MapContextService { url: layerModel.url, params: { LAYERS: layerModel.name }, gutter: 20, + attributions: layerModel.attributions, }), }) case MapContextLayerTypeEnum.WMTS: { @@ -141,6 +147,7 @@ export class MapContextService { tileGrid, projection: matrixSet.crs, dimensions, + attributions: layerModel.attributions, }) ) }) @@ -166,6 +173,7 @@ export class MapContextService { }) }, strategy: bboxStrategy, + attributions: layerModel.attributions, }) ) }) diff --git a/libs/feature/map/src/lib/utils/map-utils.service.spec.ts b/libs/feature/map/src/lib/utils/map-utils.service.spec.ts index 50afc5f787..ceb87a5d20 100644 --- a/libs/feature/map/src/lib/utils/map-utils.service.spec.ts +++ b/libs/feature/map/src/lib/utils/map-utils.service.spec.ts @@ -196,7 +196,7 @@ describe('MapUtilsService', () => { expect(map).toBeInstanceOf(Map) }) it('with no control', () => { - expect(map.getControls().getArray().length).toBe(0) + expect(map.getControls().getArray().length).toBe(3) }) it('with no layer', () => { expect(map.getLayers().getArray().length).toBe(0) 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 6e388204ea..2a73022bb8 100644 --- a/libs/feature/map/src/lib/utils/map-utils.service.ts +++ b/libs/feature/map/src/lib/utils/map-utils.service.ts @@ -26,6 +26,7 @@ import { MapContextLayerWmsModel, } from '../map-context/map-context.model' import Collection from 'ol/Collection' +import { defaults as defaultControls } from 'ol/control.js' import MapBrowserEvent from 'ol/MapBrowserEvent' import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { ProxyService } from '@geonetwork-ui/util/shared' @@ -47,7 +48,10 @@ export class MapUtilsService { createEmptyMap(): Map { return new Map({ - controls: [], + controls: defaultControls({ + attribution: true, + attributionOptions: { collapsible: false }, + }), pixelRatio: 1, }) } diff --git a/libs/ui/elements/src/lib/user-feedback-item/user-feedback-item.component.stories.ts b/libs/ui/elements/src/lib/user-feedback-item/user-feedback-item.component.stories.ts index a2803a7a04..b35d7975d8 100644 --- a/libs/ui/elements/src/lib/user-feedback-item/user-feedback-item.component.stories.ts +++ b/libs/ui/elements/src/lib/user-feedback-item/user-feedback-item.component.stories.ts @@ -83,7 +83,6 @@ export const Primary: StoryObj = { authorEmail: '', }, ], - isActiveUserEditor: true, activeUser: { id: '1', email: 'john@example.com',