Skip to content

Commit 277a86b

Browse files
ol webmap 兼容非restjsr 不处理后缀 review by luox
1 parent fb77f40 commit 277a86b

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4801,8 +4801,13 @@ export class WebMap extends Observable {
48014801
let url = dataSource.url;
48024802
if (this.isRestMapMapboxStyle(layerInfo)) {
48034803
url = url.replace(restMapMVTStr, '');
4804+
url = this.getRequestUrl(url + '.json');
4805+
}
4806+
if (url.indexOf('/restjsr/') > -1 && !/\.json$/.test(url)) {
4807+
url = this.getRequestUrl(url + '.json');
4808+
} else {
4809+
url = this.getRequestUrl(url);
48044810
}
4805-
url = this.getRequestUrl(url + '.json');
48064811

48074812
let credential = layerInfo.credential;
48084813
let credentialValue, keyfix;
@@ -4825,10 +4830,23 @@ export class WebMap extends Observable {
48254830
})
48264831
.then((result) => {
48274832
layerInfo.visibleScales = result.visibleScales;
4828-
layerInfo.coordUnit = result.coordUnit;
4833+
layerInfo.coordUnit = result.coordUnit || 'METER';
48294834
layerInfo.scale = result.scale;
4830-
layerInfo.epsgCode = result.prjCoordSys.epsgCode;
4831-
layerInfo.bounds = result.bounds;
4835+
layerInfo.epsgCode = (result.prjCoordSys && result.prjCoordSys.epsgCode) || '3857';
4836+
layerInfo.bounds = result.bounds || {
4837+
top: 20037508.342789244,
4838+
left: -20037508.342789244,
4839+
bottom: -20037508.342789244,
4840+
leftBottom: {
4841+
x: -20037508.342789244,
4842+
y: -20037508.342789244
4843+
},
4844+
right: 20037508.342789244,
4845+
rightTop: {
4846+
x: 20037508.342789244,
4847+
y: 20037508.342789244
4848+
}
4849+
};
48324850
return layerInfo;
48334851
})
48344852
.catch((error) => {
@@ -4849,7 +4867,7 @@ export class WebMap extends Observable {
48494867
let _this = this;
48504868
let url = layerInfo.url || layerInfo.dataSource.url;
48514869
let styleUrl = url;
4852-
if (styleUrl.indexOf('/restjsr/') > -1) {
4870+
if (styleUrl.indexOf('/restjsr/') > -1 && !/\/style\.json$/.test(url)) {
48534871
styleUrl = `${styleUrl}/style.json`;
48544872
}
48554873
styleUrl = this.getRequestUrl(styleUrl);

0 commit comments

Comments
 (0)