diff --git a/src/app/core/services/app-config.service.ts b/src/app/core/services/app-config.service.ts index 8a59a13488dcf4821dc365c35bd16889223f520b..b320a1e20b82bb011ab6e387642360221e506c0b 100644 --- a/src/app/core/services/app-config.service.ts +++ b/src/app/core/services/app-config.service.ts @@ -17,6 +17,9 @@ export class AppConfig { proxyQuery: string; seo: string; }; + layer3d: { + url: string; + }; theFunctionalitiesInterruptor: { credits: boolean; reuses: boolean; diff --git a/src/app/map/components/map.component.ts b/src/app/map/components/map.component.ts index 5aa6e8ae890ac6051bc1a8ed2806895d9dac5ff5..75473bb5c9c88723c62a50be6fb2b216b14b4539 100644 --- a/src/app/map/components/map.component.ts +++ b/src/app/map/components/map.component.ts @@ -2,6 +2,7 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import * as mapboxgl from 'mapbox-gl'; import { Subscription } from 'rxjs'; import { geosource } from '../../../i18n/traductions'; +import { APP_CONFIG } from '../../core/services/app-config.service'; import { linkFormats } from '../../shared/models'; import { MapOptions } from '../models/map-options'; import { GeocoderService } from '../services/geocoder.service'; @@ -211,22 +212,25 @@ export class MapComponent implements OnInit, OnDestroy { this._mapService.addLayers(); }); - this.map.on('zoomend', () => { - if (this.map.getZoom() < 14) { - this.displayButton3d = false; - - if (this.map.getLayer('3d-layer')) { - // this.display3d = false; - this.map.removeLayer('3d-layer'); - } - - } else if (this.map.getZoom() > 14) { - this.displayButton3d = true; - if (this.display3d) { - this._mapService.switch3DLayer(); + // Manage the 3d layer button only if config contains the url 3d layer + if (APP_CONFIG.layer3d) { + this.map.on('zoomend', () => { + if (this.map.getZoom() < 14) { + this.displayButton3d = false; + + if (this.map.getLayer('3d-layer')) { + // this.display3d = false; + this.map.removeLayer('3d-layer'); + } + + } else if (this.map.getZoom() > 14) { + this.displayButton3d = true; + if (this.display3d) { + this._mapService.switch3DLayer(); + } } - } - }); + }); + } } } diff --git a/src/app/map/services/map.service.ts b/src/app/map/services/map.service.ts index 054da24ca4bc7b0e51378b0c018b700f61c328c5..77ad3ec6bc160bfded5f9d65313c3e75e514e113 100644 --- a/src/app/map/services/map.service.ts +++ b/src/app/map/services/map.service.ts @@ -118,13 +118,13 @@ export class MapService { this.addWMSLayer(); // Add the 3d source. Constructed with MVT tiles from the 'fpc_fond_plan_communaut.fpctoit' dataset - const domain = this.mapOptions.vectorService.url.split('wfs')[1]; - const url = `${this.mapOptions.mvtUrl}${domain}?LAYERS= -fpc_fond_plan_communaut.fpctoit&map.imagetype=mvt&tilemode=gmap&tile={x}+{y}+{z}&mode=tile`; - this._map.addSource('3d-source', { - type: 'vector', - tiles: [url], - }); + if (APP_CONFIG.layer3d) { + const url = APP_CONFIG.layer3d.url; + this._map.addSource('3d-source', { + type: 'vector', + tiles: [url], + }); + } // Add the data layer only if it comes from the Lyon Metropole if (this.mapOptions.rasterService.url.includes(`${APP_CONFIG.backendUrls.proxyQuery}/map/wms`)) { @@ -519,7 +519,7 @@ fpc_fond_plan_communaut.fpctoit&map.imagetype=mvt&tilemode=gmap&tile={x}+{y}+{z} } switch3DLayer() { - if (!this._map.getLayer('3d-layer')) { + if (!this._map.getLayer('3d-layer') && this._map.getSource('3d-source')) { this._map.addLayer( {