Skip to content

Commit c87d1c1

Browse files
ol mapbox webmap 兼容非restjsr 不处理后缀
1 parent 0d1a486 commit c87d1c1

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

src/common/mapping/WebMapService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ export class WebMapService {
197197
});
198198
}
199199

200-
getMapBoxStyle(styleURL) {
200+
getMapBoxStyle(styleURL, withoutFormatSuffix = false) {
201201
return new Promise((resolve, reject) => {
202-
FetchRequest.get(styleURL)
202+
FetchRequest.get(styleURL, {}, { withoutFormatSuffix })
203203
.then(response => {
204204
return response.json();
205205
})

src/common/mapping/WebMapV2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,9 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, DataF
349349
if (url.indexOf('/restjsr/') > -1 && !/\/style\.json$/.test(url)) {
350350
url += '/style.json';
351351
}
352+
const withoutFormatSuffix = url.indexOf('/restjsr/') === -1;
352353
this.webMapService
353-
.getMapBoxStyle(url)
354+
.getMapBoxStyle(url, withoutFormatSuffix)
354355
.then(
355356
(style) => {
356357
const sourceIds = Object.keys(style.sources);

src/openlayers/mapping/WebMap.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4785,7 +4785,11 @@ export class WebMap extends Observable {
47854785
if (this.isRestMapMapboxStyle(layerInfo)) {
47864786
url = url.replace(restMapMVTStr, '');
47874787
}
4788-
url = this.getRequestUrl(url + '.json');
4788+
if (url.indexOf('/restjsr/') > -1 && !/\.json$/.test(url)) {
4789+
url = this.getRequestUrl(url + '.json');
4790+
} else {
4791+
url = this.getRequestUrl(url);
4792+
}
47894793

47904794
let credential = layerInfo.credential;
47914795
let credentialValue, keyfix;
@@ -4808,10 +4812,23 @@ export class WebMap extends Observable {
48084812
})
48094813
.then((result) => {
48104814
layerInfo.visibleScales = result.visibleScales;
4811-
layerInfo.coordUnit = result.coordUnit;
4815+
layerInfo.coordUnit = result.coordUnit || 'METER';
48124816
layerInfo.scale = result.scale;
4813-
layerInfo.epsgCode = result.prjCoordSys.epsgCode;
4814-
layerInfo.bounds = result.bounds;
4817+
layerInfo.epsgCode = (result.prjCoordSys && result.prjCoordSys.epsgCode) || '3857';
4818+
layerInfo.bounds = result.bounds || {
4819+
top: 20037508.342789244,
4820+
left: -20037508.342789244,
4821+
bottom: -20037508.342789244,
4822+
leftBottom: {
4823+
x: -20037508.342789244,
4824+
y: -20037508.342789244
4825+
},
4826+
right: 20037508.342789244,
4827+
rightTop: {
4828+
x: 20037508.342789244,
4829+
y: 20037508.342789244
4830+
}
4831+
};
48154832
return layerInfo;
48164833
})
48174834
.catch((error) => {
@@ -4832,7 +4849,7 @@ export class WebMap extends Observable {
48324849
let _this = this;
48334850
let url = layerInfo.url || layerInfo.dataSource.url;
48344851
let styleUrl = url;
4835-
if (styleUrl.indexOf('/restjsr/') > -1) {
4852+
if (styleUrl.indexOf('/restjsr/') > -1 && !/\/style\.json$/.test(url)) {
48364853
styleUrl = `${styleUrl}/style.json`;
48374854
}
48384855
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