From 8eeb175d879098cc6ef0ba3cb04f9d987c42fa14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Wed, 11 Sep 2019 16:22:24 -0400 Subject: [PATCH] fix(shareMap): only wms --- .../lib/share-map/shared/share-map.service.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/context/src/lib/share-map/shared/share-map.service.ts b/packages/context/src/lib/share-map/shared/share-map.service.ts index 38a5fcb10b..82748fcf97 100644 --- a/packages/context/src/lib/share-map/shared/share-map.service.ts +++ b/packages/context/src/lib/share-map/shared/share-map.service.ts @@ -88,14 +88,21 @@ export class ShareMapService { contextLayersID.push(contextLayer.id || contextLayer.source.id); } const addedLayersByService = []; - for (const layer of layers) { + for (const layer of layers.filter( + l => l.dataSource.options && l.dataSource.options.type === 'wms' + )) { if (contextLayersID.indexOf(layer.id) === -1) { const wmsUrl = (layer.dataSource.options as any).url; const addedLayer = (layer.dataSource.options as any).params.layers; const addedLayerPosition = `${addedLayer}:igoz${layer.zIndex}`; - if (!addedLayersByService.find(definedUrl => definedUrl.url === wmsUrl)) { - addedLayersByService.push({ url: wmsUrl, layers: [addedLayerPosition] }); + if ( + !addedLayersByService.find(definedUrl => definedUrl.url === wmsUrl) + ) { + addedLayersByService.push({ + url: wmsUrl, + layers: [addedLayerPosition] + }); } else { addedLayersByService.forEach(service => { if (service.url === wmsUrl) { @@ -116,8 +123,12 @@ export class ShareMapService { wmsUrlQueryParams += `${service.url},`; layersQueryParams += `(${service.layers.join(',')}),`; }); - wmsUrlQueryParams = wmsUrlQueryParams.endsWith(',') ? wmsUrlQueryParams.slice(0, -1) : wmsUrlQueryParams; - layersQueryParams = layersQueryParams.endsWith(',') ? layersQueryParams.slice(0, -1) : layersQueryParams; + wmsUrlQueryParams = wmsUrlQueryParams.endsWith(',') + ? wmsUrlQueryParams.slice(0, -1) + : wmsUrlQueryParams; + layersQueryParams = layersQueryParams.endsWith(',') + ? layersQueryParams.slice(0, -1) + : layersQueryParams; addedLayersQueryParams = `${wmsUrlKey}=${wmsUrlQueryParams}&${layersKey}=${layersQueryParams}`; } @@ -139,9 +150,7 @@ export class ShareMapService { } } - let url = `${location.origin}${ - location.pathname - }?${context}&${zoom}&${center}&${layersUrl}&${llc}&${addedLayersQueryParams}`; + let url = `${location.origin}${location.pathname}?${context}&${zoom}&${center}&${layersUrl}&${llc}&${addedLayersQueryParams}`; for (let i = 0; i < 5; i++) { url = url.replace(/&&/g, '&');