diff --git a/src/app/core/components/notifications/notifications.component.scss b/src/app/core/components/notifications/notifications.component.scss index 5380e0399e9f5d170f96614a74586b39587e5312..0888fb53f0e6bb905f8ba2f20a66931a15dc386a 100644 --- a/src/app/core/components/notifications/notifications.component.scss +++ b/src/app/core/components/notifications/notifications.component.scss @@ -4,7 +4,7 @@ $app-notification-width: 29rem; .app-notifications { position: fixed; - z-index: 1; + z-index: 10; bottom: 0.5rem; right: 0.5rem; diff --git a/src/app/geosource/components/results/result-dataset/result-dataset.component.ts b/src/app/geosource/components/results/result-dataset/result-dataset.component.ts index e576141954c6eeabc31e174d7b858bfe414353c2..f01dd90521bfc84d8c3779e651203d23c472c124 100644 --- a/src/app/geosource/components/results/result-dataset/result-dataset.component.ts +++ b/src/app/geosource/components/results/result-dataset/result-dataset.component.ts @@ -21,8 +21,6 @@ export class ResultDatasetComponent implements OnInit { constructor() { } - ngOnInit() { - console.log(this.dataset.metadata.type); - } + ngOnInit() {} } diff --git a/src/app/map/services/map.service.ts b/src/app/map/services/map.service.ts index 570d6770ad36d02d9e2d6539b2c51a085255634f..48cd62fc563fc13f7e09c2620885973344afc088 100644 --- a/src/app/map/services/map.service.ts +++ b/src/app/map/services/map.service.ts @@ -1,9 +1,9 @@ import { Injectable } from '@angular/core'; -import { Observable, Subject, BehaviorSubject, of } from 'rxjs'; +import { Observable, Subject, BehaviorSubject, of, fromEvent, Subscription } from 'rxjs'; import { Metadata, IMetadataLink } from '../../geosource/models'; import { Notification } from '../../core/models'; import * as mapboxgl from 'mapbox-gl'; -import { map, catchError } from 'rxjs/operators'; +import { map, catchError, debounceTime } from 'rxjs/operators'; import { ElasticsearchService } from '../../geosource/services/elasticsearch.service'; import { NotificationService } from '../../core/services'; import { notificationMessages } from '../../../i18n/traductions.fr'; @@ -37,6 +37,7 @@ export class MapService { private _mapSubject = new Subject<any>(); private _panelState = new BehaviorSubject<any>({ state: false }); + private _errorSubscription: Subscription; selectedFeature; // Contains the gid of the selected feature @@ -66,11 +67,20 @@ export class MapService { this.selectedBaseLayer = baseLayer; this.url = url; - this._map = new mapboxgl.Map(options).on('error', (error) => { - this._notificationService.notify(new Notification({ - message: notificationMessages.geosource.mapError, - type: 'error', - })); + this._map = new mapboxgl.Map(options); + + // Create an observable from the map error event and only emit after 1s in order + // to avoid to many error at the same time + const errorObservable = fromEvent(this._map, 'error').pipe(debounceTime(1000)); + + // Subscribe to the error observable and send a notification + this._errorSubscription = errorObservable.subscribe((v) => { + this._notificationService.notify( + new Notification({ + message: notificationMessages.geosource.mapError, + type: 'error', + }), + ); }); if (addControls) { @@ -458,6 +468,7 @@ export class MapService { destroyMap() { this._map.remove(); + this._errorSubscription.unsubscribe(); } switch3DLayer() {