Skip to content

Commit 0798683

Browse files
ol mapbox webmap 兼容非restjsr 不处理后缀 review by luox
1 parent 76bc526 commit 0798683

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4525,10 +4525,14 @@ export class WebMap extends Observable {
45254525
let dataSource = layerInfo.dataSource;
45264526
let url = dataSource.url;
45274527
if (this.isRestMapMapboxStyle(layerInfo)) {
4528-
url = url.replace(restMapMVTStr, '')
4528+
url = url.replace(restMapMVTStr, '');
4529+
url = this.getRequestUrl(url + '.json');
4530+
}
4531+
if (url.indexOf('/restjsr/') > -1 && !/\.json$/.test(url)) {
4532+
url = this.getRequestUrl(url + '.json');
4533+
} else {
4534+
url = this.getRequestUrl(url);
45294535
}
4530-
url = this.getRequestUrl(url + '.json')
4531-
45324536
let credential = layerInfo.credential;
45334537
let credentialValue,keyfix;
45344538
//携带令牌(restmap用的首字母大写,但是这里要用小写)
@@ -4548,10 +4552,23 @@ export class WebMap extends Observable {
45484552
return response.json();
45494553
}).then((result) => {
45504554
layerInfo.visibleScales = result.visibleScales;
4551-
layerInfo.coordUnit = result.coordUnit;
4555+
layerInfo.coordUnit = result.coordUnit || 'METER';
45524556
layerInfo.scale = result.scale;
4553-
layerInfo.epsgCode = result.prjCoordSys.epsgCode;
4554-
layerInfo.bounds = result.bounds;
4557+
layerInfo.epsgCode = (result.prjCoordSys && result.prjCoordSys.epsgCode) || '3857';
4558+
layerInfo.bounds = result.bounds || {
4559+
top: 20037508.342789244,
4560+
left: -20037508.342789244,
4561+
bottom: -20037508.342789244,
4562+
leftBottom: {
4563+
x: -20037508.342789244,
4564+
y: -20037508.342789244
4565+
},
4566+
right: 20037508.342789244,
4567+
rightTop: {
4568+
x: 20037508.342789244,
4569+
y: 20037508.342789244
4570+
}
4571+
};
45554572
return layerInfo;
45564573
}).catch(error => {
45574574
throw error;
@@ -4571,7 +4588,7 @@ export class WebMap extends Observable {
45714588
let _this = this;
45724589
let url = layerInfo.url || layerInfo.dataSource.url;
45734590
let styleUrl = url;
4574-
if (styleUrl.indexOf('/restjsr/') > -1) {
4591+
if (styleUrl.indexOf('/restjsr/') > -1 && !/\/style\.json$/.test(url)) {
45754592
styleUrl = `${styleUrl}/style.json`;
45764593
}
45774594
styleUrl = this.getRequestUrl(styleUrl)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy