Skip to content

Commit

Permalink
【fix】ISVJ-7398 修复带有token的restmap和叠加的数据401问题
Browse files Browse the repository at this point in the history
  • Loading branch information
songyumeng committed Dec 27, 2023
1 parent bab2faf commit 3c96df7
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/openlayers/mapping/WebMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 3c96df7

Please sign in to comment.