From 3c96df7ed212fa370644aec4be192e9f14b297f0 Mon Sep 17 00:00:00 2001 From: songyumeng Date: Wed, 27 Dec 2023 20:38:55 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=E3=80=91ISVJ-7398=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=B8=A6=E6=9C=89token=E7=9A=84restmap=E5=92=8C?= =?UTF-8?q?=E5=8F=A0=E5=8A=A0=E7=9A=84=E6=95=B0=E6=8D=AE401=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/openlayers/mapping/WebMap.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/openlayers/mapping/WebMap.js b/src/openlayers/mapping/WebMap.js index d4cd28e76..e5a04e778 100644 --- a/src/openlayers/mapping/WebMap.js +++ b/src/openlayers/mapping/WebMap.js @@ -1115,12 +1115,9 @@ export class WebMap extends Observable { */ createDynamicTiledSource(layerInfo, isBaseLayer) { let serverType = "IPORTAL", - credential = layerInfo.credential, - keyfix = 'Token', + credential = layerInfo.credential ? layerInfo.credential.token : undefined, + keyfix = 'Token', keyParams = layerInfo.url; - if (credential && credential.token) { - credential = credential.token - } if (layerInfo.url.indexOf("www.supermapol.com") > -1 || layerInfo.url.indexOf("itest.supermapol.com") > -1) { keyfix = 'Key'; @@ -1393,12 +1390,13 @@ export class WebMap extends Observable { withCredentials: this.withCredentials, withoutFormatSuffix: true }; + let tempUrl = layerInfo.url; if (layerInfo.url.indexOf("?token=") > -1) { - that.credentialKey = 'token'; - that.credentialValue = layerInfo.credential = layerInfo.url.split("?token=")[1]; + layerInfo.credential = { token: layerInfo.url.split("?token=")[1] }; layerInfo.url = layerInfo.url.split("?token=")[0]; } - return FetchRequest.get(that.getRequestUrl(`${layerInfo.url}.json`), null, options).then(function (response) { + let url = this.handleJSONSuffix(tempUrl); + return FetchRequest.get(that.getRequestUrl(url), null, options).then(function (response) { return response.json(); }).then(async function (result) { // layerInfo.projection = mapInfo.projection; @@ -5162,4 +5160,16 @@ export class WebMap extends Observable { } return ['EPSG:-1000','EPSG:-1'].includes(projection); } + handleJSONSuffix(url) { + if(!url.includes('.json')) { + if (url.includes('?')) { + let urlArr = url.split('?'); + urlArr[0] = urlArr[0] + ".json"; + url = urlArr.join('?'); + } else { + url = url + ".json" + } + } + return url; + } }