@supermapgis/iclient-ol 11.3.0 → 12.0.0-r
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/control/ChangeTileVersion.js +1 -1
- package/control/Logo.js +1 -1
- package/control/ScaleLine.js +2 -3
- package/control/index.js +1 -1
- package/core/MapExtend.js +1 -1
- package/core/StyleUtils.js +3 -3
- package/core/Util.js +2 -2
- package/core/index.js +1 -1
- package/css/index.js +1 -1
- package/dist/iclient-openlayers-es6.js +24377 -15489
- package/dist/iclient-openlayers-es6.min.js +3 -3
- package/dist/iclient-openlayers.css +2 -2
- package/dist/iclient-openlayers.js +135888 -123771
- package/dist/iclient-openlayers.min.css +2 -2
- package/dist/iclient-openlayers.min.js +3 -3
- package/index.js +1 -1
- package/mapping/BaiduMap.js +1 -2
- package/mapping/ImageSuperMapRest.js +68 -12
- package/mapping/ImageTileSuperMapRest.js +1 -1
- package/mapping/SuperMapCloud.js +1 -1
- package/mapping/Tianditu.js +1 -1
- package/mapping/TileSuperMapRest.js +1 -1
- package/mapping/WebMap.js +297 -125
- package/mapping/index.js +1 -1
- package/namespace.js +1 -1
- package/overlay/DataFlow.js +1 -1
- package/overlay/FGB.js +69 -4
- package/overlay/Graph.js +1 -1
- package/overlay/GraphMap.js +1 -1
- package/overlay/Graphic.js +1 -1
- package/overlay/HeatMap.js +1 -1
- package/overlay/Label.js +1 -1
- package/overlay/Mapv.js +1 -1
- package/overlay/Range.js +1 -1
- package/overlay/RankSymbol.js +1 -1
- package/overlay/Turf.js +1 -1
- package/overlay/Unique.js +1 -1
- package/overlay/VectorTileSuperMapRest.js +120 -87
- package/overlay/graphic/CanvasRenderer.js +1 -1
- package/overlay/graphic/CloverShape.js +1 -1
- package/overlay/graphic/Graphic.js +1 -1
- package/overlay/graphic/HitCloverShape.js +1 -1
- package/overlay/graphic/WebGLRenderer.js +1 -1
- package/overlay/graphic/index.js +1 -1
- package/overlay/index.js +1 -1
- package/overlay/mapv/MapvCanvasLayer.js +1 -1
- package/overlay/mapv/MapvLayer.js +1 -1
- package/overlay/mapv/index.js +1 -1
- package/overlay/theme/GeoFeature.js +1 -1
- package/overlay/theme/Theme.js +1 -1
- package/overlay/theme/ThemeFeature.js +1 -1
- package/overlay/theme/index.js +1 -1
- package/overlay/vectortile/DeafultCanvasStyle.js +1 -1
- package/overlay/vectortile/MapboxStyles.js +428 -389
- package/overlay/vectortile/StyleMap.js +1 -1
- package/overlay/vectortile/VectorTileStyles.js +1 -1
- package/overlay/vectortile/index.js +1 -1
- package/overlay/vectortile/olExtends.js +1 -1
- package/package.json +6 -6
- package/services/AddressMatchService.js +1 -1
- package/services/ChartService.js +1 -1
- package/services/DataFlowService.js +1 -1
- package/services/DatasetService.js +1 -1
- package/services/DatasourceService.js +1 -1
- package/services/FeatureService.js +1 -1
- package/services/FieldService.js +1 -1
- package/services/GridCellInfosService.js +1 -1
- package/services/ImageCollectionService.js +1 -1
- package/services/ImageService.js +1 -1
- package/services/KnowledgeGraphService.js +1 -1
- package/services/LayerInfoService.js +1 -1
- package/services/MapService.js +1 -1
- package/services/MeasureService.js +1 -1
- package/services/NetworkAnalyst3DService.js +1 -1
- package/services/NetworkAnalystService.js +1 -1
- package/services/ProcessingService.js +1 -1
- package/services/QueryService.js +1 -1
- package/services/ServiceBase.js +1 -1
- package/services/SpatialAnalystService.js +1 -1
- package/services/ThemeService.js +1 -1
- package/services/TrafficTransferAnalystService.js +1 -1
- package/services/WebPrintingJobService.js +1 -1
- package/services/index.js +1 -1
package/mapping/WebMap.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Copyright© 2000 -
|
|
1
|
+
/* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
|
|
2
2
|
* This program are made available under the terms of the Apache License, Version 2.0
|
|
3
3
|
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
|
|
4
4
|
import proj4 from 'proj4';
|
|
@@ -32,6 +32,7 @@ import * as olLayer from 'ol/layer';
|
|
|
32
32
|
import WMTSCapabilities from 'ol/format/WMTSCapabilities';
|
|
33
33
|
import WMSCapabilities from 'ol/format/WMSCapabilities';
|
|
34
34
|
import TileGrid from 'ol/tilegrid/TileGrid';
|
|
35
|
+
import * as olTilegrid from 'ol/tilegrid';
|
|
35
36
|
import WMTSTileGrid from 'ol/tilegrid/WMTS';
|
|
36
37
|
import * as olGeometry from 'ol/geom';
|
|
37
38
|
import Vector from 'ol/source/Vector';
|
|
@@ -83,8 +84,8 @@ const dpiConfig = {
|
|
|
83
84
|
* @param {function} [options.errorCallback] - 加载地图失败调用的函数。
|
|
84
85
|
* @param {string} [options.credentialKey] - 凭证密钥。例如为 "key"、"token",或者用户自定义的密钥。用户申请了密钥,此参数必填。
|
|
85
86
|
* @param {string} [options.credentialValue] - 凭证密钥对应的值,credentialKey 和 credentialValue 必须一起使用。
|
|
86
|
-
* @
|
|
87
|
-
* @
|
|
87
|
+
* @deprecated {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
|
|
88
|
+
* @deprecated {boolean} [options.excludePortalProxyUrl] - server 传递过来的 URL 是否带有代理。
|
|
88
89
|
* @param {Object} [options.serviceProxy] - SuperMap iPortal 内置代理信息,仅矢量瓦片图层上图才会使用。
|
|
89
90
|
* @param {string} [options.tiandituKey] - 天地图的 key。
|
|
90
91
|
* @param {string} [options.bingMapsKey] - 必应地图的 key。
|
|
@@ -115,9 +116,7 @@ export class WebMap extends Observable {
|
|
|
115
116
|
this.errorCallback = options.errorCallback;
|
|
116
117
|
this.credentialKey = options.credentialKey;
|
|
117
118
|
this.credentialValue = options.credentialValue;
|
|
118
|
-
this.withCredentials = options.withCredentials || false;
|
|
119
119
|
this.target = options.target || 'map';
|
|
120
|
-
this.excludePortalProxyUrl = options.excludePortalProxyUrl || false;
|
|
121
120
|
this.serviceProxy = options.serviceProxy || null;
|
|
122
121
|
this.tiandituKey = options.tiandituKey;
|
|
123
122
|
this.bingMapsKey = options.bingMapsKey || '';
|
|
@@ -130,6 +129,7 @@ export class WebMap extends Observable {
|
|
|
130
129
|
this.webMap = options.webMap;
|
|
131
130
|
this.tileFormat = options.tileFormat && options.tileFormat.toLowerCase();
|
|
132
131
|
this.restDataSingleRequestCount = options.restDataSingleRequestCount || 1000;
|
|
132
|
+
this.tileRequestParameters = options.tileRequestParameters;
|
|
133
133
|
this.createMap(options.mapSetting);
|
|
134
134
|
if (this.webMap) {
|
|
135
135
|
// webmap有可能是url地址,有可能是webmap对象
|
|
@@ -265,7 +265,7 @@ export class WebMap extends Observable {
|
|
|
265
265
|
}
|
|
266
266
|
mapUrl = this.server + 'web/maps/' + this.mapId + '/map';
|
|
267
267
|
let filter = 'getUrlResource.json?url=';
|
|
268
|
-
if (this.
|
|
268
|
+
if (this.server.indexOf(filter) > -1) {
|
|
269
269
|
//大屏需求,或者有加上代理的
|
|
270
270
|
let urlArray = this.server.split(filter);
|
|
271
271
|
if (urlArray.length > 1) {
|
|
@@ -291,7 +291,7 @@ export class WebMap extends Observable {
|
|
|
291
291
|
mapUrl = url;
|
|
292
292
|
}
|
|
293
293
|
FetchRequest.get(that.getRequestUrl(mapUrl), null, {
|
|
294
|
-
withCredentials:
|
|
294
|
+
withCredentials: that.isCredentail(mapUrl)
|
|
295
295
|
})
|
|
296
296
|
.then(function (response) {
|
|
297
297
|
return response.json();
|
|
@@ -380,7 +380,7 @@ export class WebMap extends Observable {
|
|
|
380
380
|
if (this.isCustomProjection(crs)) {
|
|
381
381
|
// 去iServer请求wkt 否则只能预览出图
|
|
382
382
|
await FetchRequest.get(that.getRequestUrl(`${baseLayerUrl}/prjCoordSys.wkt`), null, {
|
|
383
|
-
withCredentials: that.
|
|
383
|
+
withCredentials: that.isCredentail(baseLayerUrl),
|
|
384
384
|
withoutFormatSuffix: true
|
|
385
385
|
})
|
|
386
386
|
.then(function (response) {
|
|
@@ -431,7 +431,7 @@ export class WebMap extends Observable {
|
|
|
431
431
|
res,
|
|
432
432
|
scale,
|
|
433
433
|
resolutionArray = [],
|
|
434
|
-
coordUnit = baseLayerInfo.coordUnit || olProj.get(baseLayerInfo.projection).getUnits();
|
|
434
|
+
coordUnit = baseLayerInfo.coordUnit || baseLayerInfo.units || olProj.get(baseLayerInfo.projection).getUnits();
|
|
435
435
|
if (!coordUnit) {
|
|
436
436
|
coordUnit = this.baseProjection == 'EPSG:3857' ? 'm' : 'degree';
|
|
437
437
|
}
|
|
@@ -455,6 +455,14 @@ export class WebMap extends Observable {
|
|
|
455
455
|
resolutionArray.push(res);
|
|
456
456
|
scales.push(scale);
|
|
457
457
|
}, this);
|
|
458
|
+
} else if(baseLayerInfo.layerType === 'ZXY_TILE') {
|
|
459
|
+
const { resolutions: visibleResolution } = baseLayerInfo;
|
|
460
|
+
visibleResolution.forEach(result => {
|
|
461
|
+
const currentScale = this.getScaleFromRes(result, coordUnit);
|
|
462
|
+
resolutions[this.formatScale(currentScale)] = result;
|
|
463
|
+
scales.push(currentScale);
|
|
464
|
+
})
|
|
465
|
+
resolutionArray = visibleResolution;
|
|
458
466
|
} else {
|
|
459
467
|
let { minZoom = 0, maxZoom = 22 } = baseLayerInfo,
|
|
460
468
|
view = this.map.getView();
|
|
@@ -564,7 +572,7 @@ export class WebMap extends Observable {
|
|
|
564
572
|
if (baseLayerType === 'TILE') {
|
|
565
573
|
url = this.handleJSONSuffix(url);
|
|
566
574
|
FetchRequest.get(me.getRequestUrl(url), null, {
|
|
567
|
-
withCredentials:
|
|
575
|
+
withCredentials: me.isCredentail(url)
|
|
568
576
|
})
|
|
569
577
|
.then(function (response) {
|
|
570
578
|
return response.json();
|
|
@@ -589,9 +597,10 @@ export class WebMap extends Observable {
|
|
|
589
597
|
let options = {
|
|
590
598
|
serverType,
|
|
591
599
|
url,
|
|
592
|
-
tileGrid: TileSuperMapRest.optionsFromMapJSON(url, result).tileGrid
|
|
600
|
+
tileGrid: TileSuperMapRest.optionsFromMapJSON(url, result).tileGrid,
|
|
601
|
+
tileLoadFunction: me.getCustomTileLoadFunction()
|
|
593
602
|
};
|
|
594
|
-
if (url &&
|
|
603
|
+
if (url && this.isAddProxy(url)) {
|
|
595
604
|
options.tileProxy = me.server + 'apps/viewer/getUrlResource.png?url=';
|
|
596
605
|
}
|
|
597
606
|
source = new TileSuperMapRest(options);
|
|
@@ -604,8 +613,8 @@ export class WebMap extends Observable {
|
|
|
604
613
|
source = me.createWMSSource(baseLayerInfo);
|
|
605
614
|
me.addSpecToMap(source);
|
|
606
615
|
} else if (baseLayerType === 'WMTS') {
|
|
607
|
-
FetchRequest.get(me.getRequestUrl(url
|
|
608
|
-
withCredentials:
|
|
616
|
+
FetchRequest.get(me.getRequestUrl(url), null, {
|
|
617
|
+
withCredentials: me.isCredentail(url)
|
|
609
618
|
})
|
|
610
619
|
.then(function (response) {
|
|
611
620
|
return response.text();
|
|
@@ -772,9 +781,10 @@ export class WebMap extends Observable {
|
|
|
772
781
|
[minZoom, maxZoom] = [maxZoom, minZoom];
|
|
773
782
|
}
|
|
774
783
|
if (minZoom !== 0 || maxZoom !== visibleScales.length - 1) {
|
|
784
|
+
const oldViewOptions = this.map.getView().options_ || this.map.getView().getProperties();
|
|
775
785
|
this.map.setView(
|
|
776
786
|
new View(
|
|
777
|
-
Object.assign({},
|
|
787
|
+
Object.assign({}, oldViewOptions, {
|
|
778
788
|
maxResolution: undefined,
|
|
779
789
|
minResolution: undefined,
|
|
780
790
|
minZoom,
|
|
@@ -879,7 +889,7 @@ export class WebMap extends Observable {
|
|
|
879
889
|
) {
|
|
880
890
|
//底图有固定比例尺,就直接获取。不用view计算
|
|
881
891
|
this.getScales(baseLayer);
|
|
882
|
-
} else if (
|
|
892
|
+
} else if (baseLayer && baseLayer.layerType !=="ZXY_TILE" && extent && extent.length === 4) {
|
|
883
893
|
let width = extent[2] - extent[0];
|
|
884
894
|
let height = extent[3] - extent[1];
|
|
885
895
|
let maxResolution1 = width / 512;
|
|
@@ -893,7 +903,11 @@ export class WebMap extends Observable {
|
|
|
893
903
|
this.map.setView(new View({ zoom, center, projection, maxZoom, maxResolution }));
|
|
894
904
|
let viewOptions = {};
|
|
895
905
|
|
|
896
|
-
if (
|
|
906
|
+
if (baseLayer.layerType === "ZXY_TILE") {
|
|
907
|
+
const { resolutions, minZoom, maxZoom } = baseLayer;
|
|
908
|
+
viewOptions = { minZoom, maxZoom, zoom, center, projection, resolutions};
|
|
909
|
+
this.getScales(baseLayer);
|
|
910
|
+
} else if (
|
|
897
911
|
(baseLayer.scales && baseLayer.scales.length > 0 && baseLayer.layerType === 'WMTS') ||
|
|
898
912
|
(this.resolutionArray && this.resolutionArray.length > 0)
|
|
899
913
|
) {
|
|
@@ -988,7 +1002,8 @@ export class WebMap extends Observable {
|
|
|
988
1002
|
var layer = new olLayer.Tile({
|
|
989
1003
|
source: source,
|
|
990
1004
|
zIndex: layerInfo.zIndex || 1,
|
|
991
|
-
visible: layerInfo.visible
|
|
1005
|
+
visible: layerInfo.visible,
|
|
1006
|
+
...this.getLayerOtherOptions(layerInfo)
|
|
992
1007
|
});
|
|
993
1008
|
var layerID = Util.newGuid(8);
|
|
994
1009
|
if (layerInfo.name) {
|
|
@@ -1176,6 +1191,42 @@ export class WebMap extends Observable {
|
|
|
1176
1191
|
break;
|
|
1177
1192
|
}
|
|
1178
1193
|
}
|
|
1194
|
+
|
|
1195
|
+
getCustomTileLoadFunction(transformImageUrl) {
|
|
1196
|
+
const that = this;
|
|
1197
|
+
if (this.tileRequestParameters) {
|
|
1198
|
+
return function(imageTile, url) {
|
|
1199
|
+
const src = transformImageUrl ? transformImageUrl(url) : url;
|
|
1200
|
+
const requestParameters = that.tileRequestParameters(src);
|
|
1201
|
+
if (requestParameters) {
|
|
1202
|
+
FetchRequest.get(src, null, {
|
|
1203
|
+
...requestParameters,
|
|
1204
|
+
withoutFormatSuffix: true
|
|
1205
|
+
})
|
|
1206
|
+
.then(function (response) {
|
|
1207
|
+
return response.blob();
|
|
1208
|
+
})
|
|
1209
|
+
.then(function (blob) {
|
|
1210
|
+
const imageUrl = URL.createObjectURL(blob);
|
|
1211
|
+
imageTile.getImage().src = imageUrl;
|
|
1212
|
+
})
|
|
1213
|
+
.catch(function (error) {
|
|
1214
|
+
console.error('Error fetching the image:', error);
|
|
1215
|
+
imageTile.setState('error');
|
|
1216
|
+
});
|
|
1217
|
+
} else {
|
|
1218
|
+
imageTile.getImage().src = src;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
if(transformImageUrl) {
|
|
1223
|
+
return function(imageTile, url) {
|
|
1224
|
+
const src = transformImageUrl(url);
|
|
1225
|
+
imageTile.getImage().src = src;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1179
1230
|
/**
|
|
1180
1231
|
* @private
|
|
1181
1232
|
* @function WebMap.prototype.createDynamicTiledSource
|
|
@@ -1206,7 +1257,8 @@ export class WebMap extends Observable {
|
|
|
1206
1257
|
// crossOrigin: 'anonymous', //在IE11.0.9600版本,会影响通过注册服务打开的iserver地图,不出图。因为没有携带cookie会报跨域问题
|
|
1207
1258
|
// extent: this.baseLayerExtent,
|
|
1208
1259
|
// prjCoordSys: {epsgCode: isBaseLayer ? layerInfo.projection.split(':')[1] : this.baseProjection.split(':')[1]},
|
|
1209
|
-
format: layerInfo.format
|
|
1260
|
+
format: layerInfo.format,
|
|
1261
|
+
tileLoadFunction: this.getCustomTileLoadFunction()
|
|
1210
1262
|
};
|
|
1211
1263
|
if (!isBaseLayer && !this.isCustomProjection(this.baseProjection)) {
|
|
1212
1264
|
options.prjCoordSys = { epsgCode: this.baseProjection.split(':')[1] };
|
|
@@ -1235,9 +1287,8 @@ export class WebMap extends Observable {
|
|
|
1235
1287
|
//主机名相同时不添加代理,iportal geturlResource不支持webp代理
|
|
1236
1288
|
if (
|
|
1237
1289
|
layerInfo.url &&
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
layerInfo.format !== 'webp'
|
|
1290
|
+
layerInfo.format !== 'webp' &&
|
|
1291
|
+
this.isAddProxy(layerInfo.url, layerInfo.proxy)
|
|
1241
1292
|
) {
|
|
1242
1293
|
options.tileProxy = this.server + 'apps/viewer/getUrlResource.png?url=';
|
|
1243
1294
|
}
|
|
@@ -1320,10 +1371,38 @@ export class WebMap extends Observable {
|
|
|
1320
1371
|
return new XYZ({
|
|
1321
1372
|
url: layerInfo.url,
|
|
1322
1373
|
wrapX: false,
|
|
1323
|
-
crossOrigin: 'anonymous'
|
|
1374
|
+
crossOrigin: 'anonymous',
|
|
1375
|
+
tileLoadFunction: this.getCustomTileLoadFunction()
|
|
1324
1376
|
});
|
|
1325
1377
|
}
|
|
1326
1378
|
|
|
1379
|
+
getLayerOtherOptions(layerInfo) {
|
|
1380
|
+
const { layerType, extent, minZoom, maxZoom } = layerInfo;
|
|
1381
|
+
const extentVal = layerType === 'ZXY_TILE' ? this._getZXYTileMapBounds(layerInfo) : extent;
|
|
1382
|
+
const options = { extent: extentVal };
|
|
1383
|
+
if (typeof minZoom === 'number' && minZoom !== 0) {
|
|
1384
|
+
options.minZoom = minZoom - 1;
|
|
1385
|
+
}
|
|
1386
|
+
if (typeof maxZoom === 'number') {
|
|
1387
|
+
options.maxZoom = maxZoom;
|
|
1388
|
+
}
|
|
1389
|
+
return options;
|
|
1390
|
+
}
|
|
1391
|
+
_getZXYTileMapBounds(layerInfo) {
|
|
1392
|
+
const { mapBounds, tileSize = 256, resolutions, origin } = layerInfo;
|
|
1393
|
+
if (mapBounds) {
|
|
1394
|
+
return mapBounds;
|
|
1395
|
+
}
|
|
1396
|
+
if (resolutions) {
|
|
1397
|
+
const maxResolution = resolutions.sort((a, b) => b - a)[0];
|
|
1398
|
+
const size = maxResolution * tileSize;
|
|
1399
|
+
return [origin[0], origin[1] - size, origin[0] + size, origin[1]];
|
|
1400
|
+
}
|
|
1401
|
+
// 兼容之前的3857全球剖分
|
|
1402
|
+
if (this.baseProjection == 'EPSG:3857') {
|
|
1403
|
+
return [-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892];
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1327
1406
|
/**
|
|
1328
1407
|
* @private
|
|
1329
1408
|
* @function WebMap.prototype.createXYZTileSource
|
|
@@ -1332,17 +1411,27 @@ export class WebMap extends Observable {
|
|
|
1332
1411
|
* @returns {ol.source.XYZ} xyz的source
|
|
1333
1412
|
*/
|
|
1334
1413
|
createXYZTileSource(layerInfo) {
|
|
1335
|
-
const { url, subdomains } = layerInfo;
|
|
1336
|
-
const urls =
|
|
1337
|
-
const
|
|
1338
|
-
return new XYZ({
|
|
1414
|
+
const { url, subdomains, origin, resolutions, tileSize } = layerInfo;
|
|
1415
|
+
const urls = subdomains && subdomains.length ? subdomains.map((item) => url.replace('{s}', item)) : [url];
|
|
1416
|
+
const options = {
|
|
1339
1417
|
urls,
|
|
1340
1418
|
wrapX: false,
|
|
1341
1419
|
crossOrigin: 'anonymous',
|
|
1342
|
-
tileGrid
|
|
1343
|
-
|
|
1420
|
+
tileGrid: this._getTileGrid({ origin, resolutions, tileSize }),
|
|
1421
|
+
projection: this.baseProjection,
|
|
1422
|
+
tileLoadFunction: this.getCustomTileLoadFunction()
|
|
1423
|
+
};
|
|
1424
|
+
return new XYZ(options);
|
|
1425
|
+
}
|
|
1426
|
+
_getTileGrid({ origin, resolutions, tileSize }) {
|
|
1427
|
+
if (origin === undefined && resolutions === undefined) {
|
|
1428
|
+
// 兼容上一版webMercator全球剖分
|
|
1429
|
+
const extent = [-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892];
|
|
1430
|
+
return olTilegrid.createXYZ({ extent });
|
|
1431
|
+
} else {
|
|
1432
|
+
return new TileGrid({ origin, resolutions, tileSize });
|
|
1433
|
+
}
|
|
1344
1434
|
}
|
|
1345
|
-
|
|
1346
1435
|
/**
|
|
1347
1436
|
* @private
|
|
1348
1437
|
* @function WebMap.prototype.createWMSSource
|
|
@@ -1361,9 +1450,9 @@ export class WebMap extends Observable {
|
|
|
1361
1450
|
VERSION: layerInfo.version || '1.3.0'
|
|
1362
1451
|
},
|
|
1363
1452
|
projection: layerInfo.projection || that.baseProjection,
|
|
1364
|
-
tileLoadFunction:
|
|
1365
|
-
|
|
1366
|
-
}
|
|
1453
|
+
tileLoadFunction: this.getCustomTileLoadFunction((src) => {
|
|
1454
|
+
return that.isAddProxy(src, layerInfo.proxy) ? `${that.getProxy('png')}${encodeURIComponent(src)}`: src;
|
|
1455
|
+
})
|
|
1367
1456
|
});
|
|
1368
1457
|
}
|
|
1369
1458
|
|
|
@@ -1411,7 +1500,7 @@ export class WebMap extends Observable {
|
|
|
1411
1500
|
url = layerInfo.url.trim(),
|
|
1412
1501
|
credential = layerInfo.credential,
|
|
1413
1502
|
options = {
|
|
1414
|
-
withCredentials:
|
|
1503
|
+
withCredentials: that.isCredentail(url, layerInfo.proxy),
|
|
1415
1504
|
withoutFormatSuffix: true
|
|
1416
1505
|
};
|
|
1417
1506
|
if (isDynamic) {
|
|
@@ -1428,7 +1517,7 @@ export class WebMap extends Observable {
|
|
|
1428
1517
|
token = credential.token;
|
|
1429
1518
|
}
|
|
1430
1519
|
url = this.handleJSONSuffix(url);
|
|
1431
|
-
return FetchRequest.get(that.getRequestUrl(url), null, options)
|
|
1520
|
+
return FetchRequest.get(that.getRequestUrl(url, layerInfo.proxy), null, options)
|
|
1432
1521
|
.then(function (response) {
|
|
1433
1522
|
return response.json();
|
|
1434
1523
|
})
|
|
@@ -1438,7 +1527,7 @@ export class WebMap extends Observable {
|
|
|
1438
1527
|
}
|
|
1439
1528
|
let format = 'png';
|
|
1440
1529
|
if (that.tileFormat === 'webp') {
|
|
1441
|
-
const isSupportWebp = await that.isSupportWebp(layerInfo.url, token);
|
|
1530
|
+
const isSupportWebp = await that.isSupportWebp(layerInfo.url, token, layerInfo.proxy);
|
|
1442
1531
|
format = isSupportWebp ? 'webp' : 'png';
|
|
1443
1532
|
}
|
|
1444
1533
|
return {
|
|
@@ -1468,7 +1557,7 @@ export class WebMap extends Observable {
|
|
|
1468
1557
|
getTileInfo(layerInfo, callback, mapInfo) {
|
|
1469
1558
|
let that = this;
|
|
1470
1559
|
let options = {
|
|
1471
|
-
withCredentials:
|
|
1560
|
+
withCredentials: that.isCredentail(layerInfo.url, layerInfo.proxy),
|
|
1472
1561
|
withoutFormatSuffix: true
|
|
1473
1562
|
};
|
|
1474
1563
|
let tempUrl = layerInfo.url;
|
|
@@ -1477,7 +1566,7 @@ export class WebMap extends Observable {
|
|
|
1477
1566
|
layerInfo.url = layerInfo.url.split('?token=')[0];
|
|
1478
1567
|
}
|
|
1479
1568
|
let url = this.handleJSONSuffix(tempUrl);
|
|
1480
|
-
return FetchRequest.get(that.getRequestUrl(url), null, options)
|
|
1569
|
+
return FetchRequest.get(that.getRequestUrl(url, layerInfo.proxy), null, options)
|
|
1481
1570
|
.then(function (response) {
|
|
1482
1571
|
return response.json();
|
|
1483
1572
|
})
|
|
@@ -1501,7 +1590,7 @@ export class WebMap extends Observable {
|
|
|
1501
1590
|
that.tileFormat === 'webp' &&
|
|
1502
1591
|
layerInfo.url !== 'https://maptiles.supermapol.com/iserver/services/map_China/rest/maps/China_Dark'
|
|
1503
1592
|
) {
|
|
1504
|
-
const isSupprtWebp = await that.isSupportWebp(layerInfo.url, token);
|
|
1593
|
+
const isSupprtWebp = await that.isSupportWebp(layerInfo.url, token, layerInfo.proxy);
|
|
1505
1594
|
layerInfo.format = isSupprtWebp ? 'webp' : 'png';
|
|
1506
1595
|
}
|
|
1507
1596
|
// 请求结果完成 继续添加图层
|
|
@@ -1522,8 +1611,9 @@ export class WebMap extends Observable {
|
|
|
1522
1611
|
* @description 获取wmts请求文档的url
|
|
1523
1612
|
* @param {string} url - 图层信息。
|
|
1524
1613
|
* @param {boolean} isKvp - 是否为kvp模式
|
|
1614
|
+
* @param {boolean} proxy - 是否带上代理地址
|
|
1525
1615
|
*/
|
|
1526
|
-
getWMTSUrl(url, isKvp) {
|
|
1616
|
+
getWMTSUrl(url, isKvp, proxy) {
|
|
1527
1617
|
let splitStr = '?';
|
|
1528
1618
|
if (url.indexOf('?') > -1) {
|
|
1529
1619
|
splitStr = '&';
|
|
@@ -1533,7 +1623,7 @@ export class WebMap extends Observable {
|
|
|
1533
1623
|
} else {
|
|
1534
1624
|
url += splitStr + '/1.0.0/WMTSCapabilities.xml';
|
|
1535
1625
|
}
|
|
1536
|
-
return this.getRequestUrl(url,
|
|
1626
|
+
return this.getRequestUrl(url, proxy);
|
|
1537
1627
|
}
|
|
1538
1628
|
|
|
1539
1629
|
/**
|
|
@@ -1546,11 +1636,11 @@ export class WebMap extends Observable {
|
|
|
1546
1636
|
getWmtsInfo(layerInfo, callback) {
|
|
1547
1637
|
let that = this;
|
|
1548
1638
|
let options = {
|
|
1549
|
-
withCredentials: that.
|
|
1639
|
+
withCredentials: that.isCredentail(layerInfo.url, layerInfo.proxy),
|
|
1550
1640
|
withoutFormatSuffix: true
|
|
1551
1641
|
};
|
|
1552
1642
|
const isKvp = !layerInfo.requestEncoding || layerInfo.requestEncoding === 'KVP';
|
|
1553
|
-
return FetchRequest.get(that.getWMTSUrl(layerInfo.url, isKvp), null, options)
|
|
1643
|
+
return FetchRequest.get(that.getWMTSUrl(layerInfo.url, isKvp, layerInfo.proxy), null, options)
|
|
1554
1644
|
.then(function (response) {
|
|
1555
1645
|
return response.text();
|
|
1556
1646
|
})
|
|
@@ -1653,12 +1743,12 @@ export class WebMap extends Observable {
|
|
|
1653
1743
|
let url = layerInfo.url.trim();
|
|
1654
1744
|
url += url.indexOf('?') > -1 ? '&SERVICE=WMS&REQUEST=GetCapabilities' : '?SERVICE=WMS&REQUEST=GetCapabilities';
|
|
1655
1745
|
let options = {
|
|
1656
|
-
withCredentials: that.
|
|
1746
|
+
withCredentials: that.isCredentail(url, layerInfo.proxy),
|
|
1657
1747
|
withoutFormatSuffix: true
|
|
1658
1748
|
};
|
|
1659
1749
|
|
|
1660
1750
|
let promise = new Promise(function (resolve) {
|
|
1661
|
-
return FetchRequest.get(that.getRequestUrl(url,
|
|
1751
|
+
return FetchRequest.get(that.getRequestUrl(url, layerInfo.proxy), null, options)
|
|
1662
1752
|
.then(function (response) {
|
|
1663
1753
|
return response.text();
|
|
1664
1754
|
})
|
|
@@ -1740,7 +1830,7 @@ export class WebMap extends Observable {
|
|
|
1740
1830
|
|
|
1741
1831
|
// 单位通过坐标系获取 (PS: 以前代码非4326 都默认是米)
|
|
1742
1832
|
let unit = olProj.get(this.baseProjection).getUnits();
|
|
1743
|
-
|
|
1833
|
+
const that = this;
|
|
1744
1834
|
return new WMTS({
|
|
1745
1835
|
url: layerInfo.tileUrl || layerInfo.url,
|
|
1746
1836
|
layer: layerInfo.layer,
|
|
@@ -1756,13 +1846,15 @@ export class WebMap extends Observable {
|
|
|
1756
1846
|
layerInfo.origin,
|
|
1757
1847
|
layerInfo.matrixIds
|
|
1758
1848
|
),
|
|
1759
|
-
tileLoadFunction: function (
|
|
1849
|
+
tileLoadFunction: this.getCustomTileLoadFunction(function (src) {
|
|
1760
1850
|
if (src.indexOf('tianditu.gov.cn') >= 0) {
|
|
1761
|
-
|
|
1762
|
-
return;
|
|
1851
|
+
return `${src}&tk=${CommonUtil.getParameters(layerInfo.url)['tk']}`;
|
|
1763
1852
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1853
|
+
if(that.isAddProxy(src, layerInfo.proxy)) {
|
|
1854
|
+
return `${that.getProxy('png')}${encodeURIComponent(src)}`;
|
|
1855
|
+
}
|
|
1856
|
+
return src;
|
|
1857
|
+
})
|
|
1766
1858
|
});
|
|
1767
1859
|
}
|
|
1768
1860
|
|
|
@@ -1913,7 +2005,7 @@ export class WebMap extends Observable {
|
|
|
1913
2005
|
await that.addLayer(layer, null, layerIndex);
|
|
1914
2006
|
that.layerAdded++;
|
|
1915
2007
|
that.sendMapToUser(len);
|
|
1916
|
-
|
|
2008
|
+
continue;
|
|
1917
2009
|
}
|
|
1918
2010
|
if (
|
|
1919
2011
|
layer.layerType === 'MARKER' ||
|
|
@@ -1924,9 +2016,9 @@ export class WebMap extends Observable {
|
|
|
1924
2016
|
let url = isSampleData
|
|
1925
2017
|
? `${that.server}apps/dataviz/libs/sample-datas/${dataSource.name}.json`
|
|
1926
2018
|
: `${that.server}web/datas/${serverId}/content.json?pageSize=9999999¤tPage=1`;
|
|
1927
|
-
url = that.getRequestUrl(url);
|
|
2019
|
+
url = that.getRequestUrl(url, layer.proxy);
|
|
1928
2020
|
FetchRequest.get(url, null, {
|
|
1929
|
-
withCredentials:
|
|
2021
|
+
withCredentials: that.isCredentail(url, layer.proxy)
|
|
1930
2022
|
})
|
|
1931
2023
|
.then(function (response) {
|
|
1932
2024
|
return response.json();
|
|
@@ -1948,7 +2040,7 @@ export class WebMap extends Observable {
|
|
|
1948
2040
|
//行政规划信息
|
|
1949
2041
|
data.content.rows.unshift(data.content.colTitles);
|
|
1950
2042
|
let { divisionType, divisionField } = layer.dataSource.administrativeInfo;
|
|
1951
|
-
let geojson = that.excelData2FeatureByDivision(data.content, divisionType, divisionField);
|
|
2043
|
+
let geojson = await that.excelData2FeatureByDivision(data.content, divisionType, divisionField);
|
|
1952
2044
|
features = that._parseGeoJsonData2Feature({
|
|
1953
2045
|
allDatas: { features: geojson.features },
|
|
1954
2046
|
fileCode: layer.projection
|
|
@@ -1993,7 +2085,7 @@ export class WebMap extends Observable {
|
|
|
1993
2085
|
//需要判断是使用tile还是mvt服务
|
|
1994
2086
|
let dataService = that.getService(dataItemServices, 'RESTDATA');
|
|
1995
2087
|
that
|
|
1996
|
-
.isMvt(dataService.address, datasetName)
|
|
2088
|
+
.isMvt(dataService.address, datasetName, layer.proxy)
|
|
1997
2089
|
.then(async (info) => {
|
|
1998
2090
|
await that.getServiceInfoFromLayer(
|
|
1999
2091
|
layerIndex,
|
|
@@ -2040,7 +2132,7 @@ export class WebMap extends Observable {
|
|
|
2040
2132
|
});
|
|
2041
2133
|
}
|
|
2042
2134
|
} else if (dataSource && dataSource.type === 'USER_DATA') {
|
|
2043
|
-
that.addGeojsonFromUrl(layer, len, layerIndex
|
|
2135
|
+
that.addGeojsonFromUrl(layer, len, layerIndex);
|
|
2044
2136
|
} else if (layer.layerType === 'TILE') {
|
|
2045
2137
|
that.getTileLayerExtent(
|
|
2046
2138
|
layer,
|
|
@@ -2144,15 +2236,14 @@ export class WebMap extends Observable {
|
|
|
2144
2236
|
* @param {Object} layerInfo - 图层信息
|
|
2145
2237
|
* @param {number} len - 总的图层数量
|
|
2146
2238
|
* @param {number} layerIndex - 当前图层index
|
|
2147
|
-
* @param {boolean} withCredentials - 是否携带cookie
|
|
2148
2239
|
*/
|
|
2149
|
-
addGeojsonFromUrl(layerInfo, len, layerIndex
|
|
2240
|
+
addGeojsonFromUrl(layerInfo, len, layerIndex) {
|
|
2150
2241
|
// 通过web添加geojson不需要携带cookie
|
|
2151
2242
|
let { dataSource } = layerInfo,
|
|
2152
2243
|
{ url } = dataSource,
|
|
2153
2244
|
that = this;
|
|
2154
2245
|
FetchRequest.get(url, null, {
|
|
2155
|
-
withCredentials,
|
|
2246
|
+
withCredentials: that.isCredentail(url),
|
|
2156
2247
|
withoutFormatSuffix: true
|
|
2157
2248
|
})
|
|
2158
2249
|
.then(function (response) {
|
|
@@ -2231,7 +2322,7 @@ export class WebMap extends Observable {
|
|
|
2231
2322
|
if (service && isMapService && service.serviceType === 'RESTMAP') {
|
|
2232
2323
|
isAdded = true;
|
|
2233
2324
|
//地图服务,判断使用mvt还是tile
|
|
2234
|
-
that.getTileLayerInfo(service.address).then(function (restMaps) {
|
|
2325
|
+
that.getTileLayerInfo(service.address, layer.proxy).then(function (restMaps) {
|
|
2235
2326
|
restMaps.forEach(function (restMapInfo) {
|
|
2236
2327
|
let bounds = restMapInfo.bounds;
|
|
2237
2328
|
layer.layerType = 'TILE';
|
|
@@ -2298,13 +2389,13 @@ export class WebMap extends Observable {
|
|
|
2298
2389
|
let url = layerInfo.url,
|
|
2299
2390
|
token;
|
|
2300
2391
|
url = this.handleJSONSuffix(url);
|
|
2301
|
-
let requestUrl = that.getRequestUrl(url,
|
|
2392
|
+
let requestUrl = that.getRequestUrl(url, layerInfo.proxy);
|
|
2302
2393
|
if (layerInfo.credential && layerInfo.credential.token) {
|
|
2303
2394
|
token = layerInfo.credential.token;
|
|
2304
2395
|
requestUrl += `?token=${token}`;
|
|
2305
2396
|
}
|
|
2306
2397
|
FetchRequest.get(requestUrl, null, {
|
|
2307
|
-
withCredentials:
|
|
2398
|
+
withCredentials: that.isCredentail(url, layerInfo.proxy)
|
|
2308
2399
|
})
|
|
2309
2400
|
.then(function (response) {
|
|
2310
2401
|
return response.json();
|
|
@@ -2337,11 +2428,9 @@ export class WebMap extends Observable {
|
|
|
2337
2428
|
dataSourceName = dataSource.dataSourceName || layer.name;
|
|
2338
2429
|
let requestUrl = that.formatUrlWithCredential(url),
|
|
2339
2430
|
serviceOptions = {};
|
|
2340
|
-
serviceOptions.withCredentials = this.
|
|
2431
|
+
serviceOptions.withCredentials = this.isCredentail(url, layer.proxy);
|
|
2341
2432
|
if (
|
|
2342
|
-
|
|
2343
|
-
!CommonUtil.isInTheSameDomain(requestUrl) &&
|
|
2344
|
-
!this.isIportalProxyServiceUrl(requestUrl)
|
|
2433
|
+
that.isAddProxy(requestUrl, layer.proxy)
|
|
2345
2434
|
) {
|
|
2346
2435
|
serviceOptions.proxy = this.getProxy();
|
|
2347
2436
|
}
|
|
@@ -2463,8 +2552,9 @@ export class WebMap extends Observable {
|
|
|
2463
2552
|
if (layerInfo.layerType === 'MIGRATION') {
|
|
2464
2553
|
try {
|
|
2465
2554
|
if (dataSource.type === 'PORTAL_DATA') {
|
|
2466
|
-
const
|
|
2467
|
-
|
|
2555
|
+
const requestUrl = `${this.server}web/datas/${dataSource.serverId}.json`;
|
|
2556
|
+
const { dataMetaInfo } = await FetchRequest.get(requestUrl, null, {
|
|
2557
|
+
withCredentials: this.isCredentail(requestUrl)
|
|
2468
2558
|
}).then((res) => res.json());
|
|
2469
2559
|
// eslint-disable-next-line require-atomic-updates
|
|
2470
2560
|
layerInfo.xyField = {
|
|
@@ -2538,7 +2628,7 @@ export class WebMap extends Observable {
|
|
|
2538
2628
|
* @returns {Object} geojson对象
|
|
2539
2629
|
*/
|
|
2540
2630
|
excelData2FeatureByDivision(content, divisionType, divisionField) {
|
|
2541
|
-
|
|
2631
|
+
|
|
2542
2632
|
let asyncInport;
|
|
2543
2633
|
if (divisionType === 'Province') {
|
|
2544
2634
|
asyncInport = window.ProvinceData;
|
|
@@ -2548,10 +2638,33 @@ export class WebMap extends Observable {
|
|
|
2548
2638
|
// let geojso;
|
|
2549
2639
|
asyncInport = window.AdministrativeArea;
|
|
2550
2640
|
}
|
|
2551
|
-
if
|
|
2552
|
-
|
|
2553
|
-
|
|
2641
|
+
if(asyncInport){
|
|
2642
|
+
return new Promise(resolve => {
|
|
2643
|
+
resolve(this.changeExcel2Geojson(asyncInport.features, content.rows, divisionType, divisionField));
|
|
2644
|
+
});
|
|
2645
|
+
}
|
|
2646
|
+
if(divisionType === 'GB-T_2260'){
|
|
2647
|
+
return new Promise(resolve => {
|
|
2648
|
+
resolve({
|
|
2649
|
+
type: 'FeatureCollection',
|
|
2650
|
+
features: []
|
|
2651
|
+
});
|
|
2652
|
+
});
|
|
2554
2653
|
}
|
|
2654
|
+
const dataName = divisionType === 'City' ? 'MunicipalData' : 'ProvinceData';
|
|
2655
|
+
const dataFileName = divisionType === 'City' ? 'MunicipalData.js' : 'ProvincialData.js';
|
|
2656
|
+
const dataUrl = CommonUtil.urlPathAppend(this.server,`apps/dataviz/libs/administrative_data/${dataFileName}`);
|
|
2657
|
+
return FetchRequest.get(this.getRequestUrl(dataUrl), null, {
|
|
2658
|
+
withCredentials: this.isCredentail(dataUrl),
|
|
2659
|
+
withoutFormatSuffix: true
|
|
2660
|
+
})
|
|
2661
|
+
.then(response => {
|
|
2662
|
+
return response.text();
|
|
2663
|
+
})
|
|
2664
|
+
.then(result => {
|
|
2665
|
+
new Function(result)();
|
|
2666
|
+
return this.changeExcel2Geojson(window[dataName].features, content.rows, divisionType, divisionField);
|
|
2667
|
+
});
|
|
2555
2668
|
}
|
|
2556
2669
|
|
|
2557
2670
|
/**
|
|
@@ -2609,10 +2722,13 @@ export class WebMap extends Observable {
|
|
|
2609
2722
|
if (feature) {
|
|
2610
2723
|
let newFeature = (window.cloneDeep || cloneDeep)(feature);
|
|
2611
2724
|
newFeature.properties = {};
|
|
2725
|
+
const titleLen = titles.length;
|
|
2612
2726
|
row.forEach((item, idx) => {
|
|
2613
2727
|
//空格问题,看见DV多处处理空格问题,TODO统一整理
|
|
2614
|
-
|
|
2615
|
-
|
|
2728
|
+
if (idx < titleLen) {
|
|
2729
|
+
let key = titles[idx].trim();
|
|
2730
|
+
newFeature.properties[key] = item;
|
|
2731
|
+
}
|
|
2616
2732
|
});
|
|
2617
2733
|
geojson.features.push(newFeature);
|
|
2618
2734
|
}
|
|
@@ -2872,11 +2988,9 @@ export class WebMap extends Observable {
|
|
|
2872
2988
|
} else {
|
|
2873
2989
|
let requestUrl = that.formatUrlWithCredential(url),
|
|
2874
2990
|
serviceOptions = {};
|
|
2875
|
-
serviceOptions.withCredentials =
|
|
2991
|
+
serviceOptions.withCredentials = that.isCredentail(requestUrl);
|
|
2876
2992
|
if (
|
|
2877
|
-
|
|
2878
|
-
!CommonUtil.isInTheSameDomain(requestUrl) &&
|
|
2879
|
-
!this.isIportalProxyServiceUrl(requestUrl)
|
|
2993
|
+
that.isAddProxy(requestUrl)
|
|
2880
2994
|
) {
|
|
2881
2995
|
serviceOptions.proxy = this.getProxy();
|
|
2882
2996
|
}
|
|
@@ -2958,13 +3072,15 @@ export class WebMap extends Observable {
|
|
|
2958
3072
|
};
|
|
2959
3073
|
let featureType = layerInfo.featureType;
|
|
2960
3074
|
let style = await StyleUtils.toOpenLayersStyle(this.getDataVectorTileStyle(featureType), featureType);
|
|
3075
|
+
const requestParameters = this.tileRequestParameters && this.tileRequestParameters(layerInfo.url);
|
|
2961
3076
|
return new olLayer.VectorTile({
|
|
2962
3077
|
//设置避让参数
|
|
2963
3078
|
source: new VectorTileSuperMapRest({
|
|
2964
3079
|
url: layerInfo.url,
|
|
2965
3080
|
projection: layerInfo.projection,
|
|
2966
3081
|
tileType: 'ScaleXY',
|
|
2967
|
-
format: format
|
|
3082
|
+
format: format,
|
|
3083
|
+
...requestParameters
|
|
2968
3084
|
}),
|
|
2969
3085
|
style: style
|
|
2970
3086
|
});
|
|
@@ -4200,7 +4316,7 @@ export class WebMap extends Observable {
|
|
|
4200
4316
|
checkUploadToRelationship(fileId) {
|
|
4201
4317
|
let url = this.getRequestUrl(`${this.server}web/datas/${fileId}/datasets.json`);
|
|
4202
4318
|
return FetchRequest.get(url, null, {
|
|
4203
|
-
withCredentials: this.
|
|
4319
|
+
withCredentials: this.isCredentail(url)
|
|
4204
4320
|
})
|
|
4205
4321
|
.then(function (response) {
|
|
4206
4322
|
return response.json();
|
|
@@ -4219,7 +4335,7 @@ export class WebMap extends Observable {
|
|
|
4219
4335
|
getDatasources(url) {
|
|
4220
4336
|
let requestUrl = this.getRequestUrl(`${url}/data/datasources.json`);
|
|
4221
4337
|
return FetchRequest.get(requestUrl, null, {
|
|
4222
|
-
withCredentials: this.
|
|
4338
|
+
withCredentials: this.isCredentail(requestUrl)
|
|
4223
4339
|
})
|
|
4224
4340
|
.then(function (response) {
|
|
4225
4341
|
return response.json();
|
|
@@ -4240,7 +4356,7 @@ export class WebMap extends Observable {
|
|
|
4240
4356
|
getDataService(fileId, datasetName) {
|
|
4241
4357
|
let url = this.getRequestUrl(`${this.server}web/datas/${fileId}.json`);
|
|
4242
4358
|
return FetchRequest.get(url, null, {
|
|
4243
|
-
withCredentials: this.
|
|
4359
|
+
withCredentials: this.isCredentail(url)
|
|
4244
4360
|
})
|
|
4245
4361
|
.then(function (response) {
|
|
4246
4362
|
return response.json();
|
|
@@ -4252,23 +4368,41 @@ export class WebMap extends Observable {
|
|
|
4252
4368
|
});
|
|
4253
4369
|
}
|
|
4254
4370
|
|
|
4371
|
+
/**
|
|
4372
|
+
* 请求是否带上cookie
|
|
4373
|
+
* @param {string} url 请求地址,必选参数。
|
|
4374
|
+
* @param {boolean} proxy 是否需要加上代理,可选参数。
|
|
4375
|
+
* @returns { boolean | undefined } 是否带上cookie
|
|
4376
|
+
*/
|
|
4377
|
+
isCredentail(url, proxy) {
|
|
4378
|
+
if(proxy || this.isIportalProxyServiceUrl(url) || CommonUtil.isInTheSameDomain(url)) {
|
|
4379
|
+
return true
|
|
4380
|
+
}
|
|
4381
|
+
return;
|
|
4382
|
+
}
|
|
4383
|
+
/**
|
|
4384
|
+
* url是否要带上代理
|
|
4385
|
+
* @param {*} url 请求地址,必选参数。
|
|
4386
|
+
* @param {*} proxy 是否需要加上代理,可选参数。
|
|
4387
|
+
* @returns { boolean } 是否带上代理
|
|
4388
|
+
*/
|
|
4389
|
+
isAddProxy(url, proxy) {
|
|
4390
|
+
return !CommonUtil.isInTheSameDomain(url) && !this.isIportalProxyServiceUrl(url) && proxy !== false;
|
|
4391
|
+
}
|
|
4392
|
+
|
|
4255
4393
|
/**
|
|
4256
4394
|
* @private
|
|
4257
4395
|
* @function WebMap.prototype.getRootUrl
|
|
4258
4396
|
* @description 获取请求地址。
|
|
4259
4397
|
* @param {string} url 请求的地址。
|
|
4260
|
-
* @param {boolean}
|
|
4398
|
+
* @param {boolean | undefined} proxy 是否带上代理。
|
|
4261
4399
|
* @returns {Promise<T | never>} 请求地址。
|
|
4262
4400
|
*/
|
|
4263
|
-
getRequestUrl(url,
|
|
4264
|
-
url =
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
}
|
|
4269
|
-
return CommonUtil.isInTheSameDomain(url) || this.isIportalProxyServiceUrl(url)
|
|
4270
|
-
? url
|
|
4271
|
-
: `${this.getProxy()}${encodeURIComponent(url)}`;
|
|
4401
|
+
getRequestUrl(url, proxy) {
|
|
4402
|
+
url = this.formatUrlWithCredential(url);
|
|
4403
|
+
return this.isAddProxy(url, proxy) ?
|
|
4404
|
+
`${this.getProxy()}${encodeURIComponent(url)}`:
|
|
4405
|
+
url
|
|
4272
4406
|
}
|
|
4273
4407
|
|
|
4274
4408
|
/**
|
|
@@ -4304,14 +4438,15 @@ export class WebMap extends Observable {
|
|
|
4304
4438
|
* @function WebMap.prototype.getTileLayerInfo
|
|
4305
4439
|
* @description 获取地图服务的信息
|
|
4306
4440
|
* @param {string} url 地图服务的url(没有地图名字)
|
|
4441
|
+
* @param {boolean | undefined} proxy 是否需要代理
|
|
4307
4442
|
* @returns {Promise<T | never>} 地图服务信息
|
|
4308
4443
|
*/
|
|
4309
|
-
getTileLayerInfo(url) {
|
|
4444
|
+
getTileLayerInfo(url, proxy) {
|
|
4310
4445
|
let that = this,
|
|
4311
4446
|
epsgCode = that.baseProjection.split('EPSG:')[1];
|
|
4312
|
-
let requestUrl = that.getRequestUrl(`${url}/maps.json
|
|
4447
|
+
let requestUrl = that.getRequestUrl(`${url}/maps.json`, proxy);
|
|
4313
4448
|
return FetchRequest.get(requestUrl, null, {
|
|
4314
|
-
withCredentials: this.
|
|
4449
|
+
withCredentials: this.isCredentail(url, proxy)
|
|
4315
4450
|
})
|
|
4316
4451
|
.then(function (response) {
|
|
4317
4452
|
return response.json();
|
|
@@ -4321,10 +4456,11 @@ export class WebMap extends Observable {
|
|
|
4321
4456
|
if (mapInfo) {
|
|
4322
4457
|
mapInfo.forEach(function (info) {
|
|
4323
4458
|
let mapUrl = that.getRequestUrl(
|
|
4324
|
-
`${info.path}.json?prjCoordSys=${encodeURI(JSON.stringify({ epsgCode: epsgCode }))}
|
|
4459
|
+
`${info.path}.json?prjCoordSys=${encodeURI(JSON.stringify({ epsgCode: epsgCode }))}`,
|
|
4460
|
+
proxy
|
|
4325
4461
|
);
|
|
4326
4462
|
let promise = FetchRequest.get(mapUrl, null, {
|
|
4327
|
-
withCredentials: that.
|
|
4463
|
+
withCredentials: that.isCredentail(mapUrl, proxy)
|
|
4328
4464
|
})
|
|
4329
4465
|
.then(function (response) {
|
|
4330
4466
|
return response.json();
|
|
@@ -4668,15 +4804,16 @@ export class WebMap extends Observable {
|
|
|
4668
4804
|
* @description 判断当前能否使用数据服务的mvt上图方式
|
|
4669
4805
|
* @param {string} serviceUrl 数据服务的地址
|
|
4670
4806
|
* @param {string} datasetName 数据服务的数据集名称
|
|
4807
|
+
* @param {boolean | undefined} proxy 是否带上代理
|
|
4671
4808
|
* @returns {Object} 数据服务的信息
|
|
4672
4809
|
*/
|
|
4673
|
-
isMvt(serviceUrl, datasetName) {
|
|
4810
|
+
isMvt(serviceUrl, datasetName, proxy) {
|
|
4674
4811
|
let that = this;
|
|
4675
4812
|
return this.getDatasetsInfo(serviceUrl, datasetName).then((info) => {
|
|
4676
4813
|
//判断是否和底图坐标系一直
|
|
4677
4814
|
if (info.epsgCode == that.baseProjection.split('EPSG:')[1]) {
|
|
4678
|
-
return FetchRequest.get(that.getRequestUrl(`${info.url}/tilefeature.mvt
|
|
4679
|
-
withCredentials: that.
|
|
4815
|
+
return FetchRequest.get(that.getRequestUrl(`${info.url}/tilefeature.mvt`, proxy), null, {
|
|
4816
|
+
withCredentials: that.isCredentail(info.url, proxy)
|
|
4680
4817
|
})
|
|
4681
4818
|
.then(function (response) {
|
|
4682
4819
|
return response.json();
|
|
@@ -4707,7 +4844,7 @@ export class WebMap extends Observable {
|
|
|
4707
4844
|
//判断mvt服务是否可用
|
|
4708
4845
|
let url = `${serviceUrl}/data/datasources/${datasourceName}/datasets/${datasetName}.json`;
|
|
4709
4846
|
return FetchRequest.get(that.getRequestUrl(url), null, {
|
|
4710
|
-
withCredentials: that.
|
|
4847
|
+
withCredentials: that.isCredentail(url)
|
|
4711
4848
|
})
|
|
4712
4849
|
.then(function (response) {
|
|
4713
4850
|
return response.json();
|
|
@@ -4784,8 +4921,13 @@ export class WebMap extends Observable {
|
|
|
4784
4921
|
let url = dataSource.url;
|
|
4785
4922
|
if (this.isRestMapMapboxStyle(layerInfo)) {
|
|
4786
4923
|
url = url.replace(restMapMVTStr, '');
|
|
4924
|
+
url = this.getRequestUrl(url + '.json');
|
|
4925
|
+
}
|
|
4926
|
+
if (url.indexOf('/restjsr/') > -1 && !/\.json$/.test(url)) {
|
|
4927
|
+
url = this.getRequestUrl(url + '.json');
|
|
4928
|
+
} else {
|
|
4929
|
+
url = this.getRequestUrl(url);
|
|
4787
4930
|
}
|
|
4788
|
-
url = this.getRequestUrl(url + '.json');
|
|
4789
4931
|
|
|
4790
4932
|
let credential = layerInfo.credential;
|
|
4791
4933
|
let credentialValue, keyfix;
|
|
@@ -4797,7 +4939,7 @@ export class WebMap extends Observable {
|
|
|
4797
4939
|
}
|
|
4798
4940
|
|
|
4799
4941
|
return FetchRequest.get(url, null, {
|
|
4800
|
-
withCredentials: this.
|
|
4942
|
+
withCredentials: this.isCredentail(url),
|
|
4801
4943
|
withoutFormatSuffix: true,
|
|
4802
4944
|
headers: {
|
|
4803
4945
|
'Content-Type': 'application/json;chartset=uft-8'
|
|
@@ -4808,10 +4950,23 @@ export class WebMap extends Observable {
|
|
|
4808
4950
|
})
|
|
4809
4951
|
.then((result) => {
|
|
4810
4952
|
layerInfo.visibleScales = result.visibleScales;
|
|
4811
|
-
layerInfo.coordUnit = result.coordUnit;
|
|
4953
|
+
layerInfo.coordUnit = result.coordUnit || 'METER';
|
|
4812
4954
|
layerInfo.scale = result.scale;
|
|
4813
|
-
layerInfo.epsgCode = result.prjCoordSys.epsgCode;
|
|
4814
|
-
layerInfo.bounds = result.bounds
|
|
4955
|
+
layerInfo.epsgCode = (result.prjCoordSys && result.prjCoordSys.epsgCode) || '3857';
|
|
4956
|
+
layerInfo.bounds = result.bounds || {
|
|
4957
|
+
top: 20037508.342789244,
|
|
4958
|
+
left: -20037508.342789244,
|
|
4959
|
+
bottom: -20037508.342789244,
|
|
4960
|
+
leftBottom: {
|
|
4961
|
+
x: -20037508.342789244,
|
|
4962
|
+
y: -20037508.342789244
|
|
4963
|
+
},
|
|
4964
|
+
right: 20037508.342789244,
|
|
4965
|
+
rightTop: {
|
|
4966
|
+
x: 20037508.342789244,
|
|
4967
|
+
y: 20037508.342789244
|
|
4968
|
+
}
|
|
4969
|
+
};
|
|
4815
4970
|
return layerInfo;
|
|
4816
4971
|
})
|
|
4817
4972
|
.catch((error) => {
|
|
@@ -4832,7 +4987,7 @@ export class WebMap extends Observable {
|
|
|
4832
4987
|
let _this = this;
|
|
4833
4988
|
let url = layerInfo.url || layerInfo.dataSource.url;
|
|
4834
4989
|
let styleUrl = url;
|
|
4835
|
-
if (styleUrl.indexOf('/restjsr/') > -1) {
|
|
4990
|
+
if (styleUrl.indexOf('/restjsr/') > -1 && !/\/style\.json$/.test(url)) {
|
|
4836
4991
|
styleUrl = `${styleUrl}/style.json`;
|
|
4837
4992
|
}
|
|
4838
4993
|
styleUrl = this.getRequestUrl(styleUrl);
|
|
@@ -4846,7 +5001,7 @@ export class WebMap extends Observable {
|
|
|
4846
5001
|
}
|
|
4847
5002
|
|
|
4848
5003
|
return FetchRequest.get(styleUrl, null, {
|
|
4849
|
-
withCredentials: this.
|
|
5004
|
+
withCredentials: this.isCredentail(styleUrl),
|
|
4850
5005
|
withoutFormatSuffix: true,
|
|
4851
5006
|
headers: {
|
|
4852
5007
|
'Content-Type': 'application/json;chartset=uft-8'
|
|
@@ -4865,7 +5020,8 @@ export class WebMap extends Observable {
|
|
|
4865
5020
|
let sourcesNames = Object.keys(sources);
|
|
4866
5021
|
sourcesNames.forEach(function (sourceName) {
|
|
4867
5022
|
styles.sources[sourceName].tiles.forEach(function (tiles, i) {
|
|
4868
|
-
|
|
5023
|
+
const splicing = tiles.includes('?') ? '&' : '?';
|
|
5024
|
+
styles.sources[sourceName].tiles[i] = `${tiles}${splicing}${keyfix}=${credentialValue}`;
|
|
4869
5025
|
});
|
|
4870
5026
|
});
|
|
4871
5027
|
}
|
|
@@ -5063,7 +5219,6 @@ export class WebMap extends Observable {
|
|
|
5063
5219
|
* @param {Object} layerInfo - 图层信息
|
|
5064
5220
|
*/
|
|
5065
5221
|
createMVTLayer(layerInfo) {
|
|
5066
|
-
// let that = this;
|
|
5067
5222
|
let styles = layerInfo.styles;
|
|
5068
5223
|
const indexbounds = styles && styles.metadata && styles.metadata.indexbounds;
|
|
5069
5224
|
const visibleResolution = this.createVisibleResolution(
|
|
@@ -5075,14 +5230,36 @@ export class WebMap extends Observable {
|
|
|
5075
5230
|
const envelope = this.getEnvelope(indexbounds, layerInfo.bounds);
|
|
5076
5231
|
const styleResolutions = this.getStyleResolutions(envelope);
|
|
5077
5232
|
// const origin = [envelope.left, envelope.top];
|
|
5078
|
-
let
|
|
5233
|
+
let baseUrl = layerInfo.url;
|
|
5234
|
+
let paramUrl = baseUrl.split('?')[1];
|
|
5235
|
+
if (layerInfo.dataSource.type === 'ARCGIS_VECTORTILE') {
|
|
5236
|
+
Object.keys(styles.sources).forEach(function (key) {
|
|
5237
|
+
Object.keys(styles.sources[key]).forEach(function(fieldName) {
|
|
5238
|
+
if (fieldName === 'url') {
|
|
5239
|
+
if (typeof styles.sources[key][fieldName] === 'string' && !CommonUtil.isAbsoluteURL(styles.sources[key][fieldName])) {
|
|
5240
|
+
styles.sources[key][fieldName] = CommonUtil.relative2absolute(styles.sources[key][fieldName], baseUrl);
|
|
5241
|
+
}
|
|
5242
|
+
styles.sources[key][fieldName] = styles.sources[key][fieldName] + (paramUrl ? '?' + paramUrl + '&f=json' : '?f=json');
|
|
5243
|
+
}
|
|
5244
|
+
});
|
|
5245
|
+
});
|
|
5246
|
+
}
|
|
5247
|
+
let sourceName = Object.keys(styles.sources)[0];
|
|
5248
|
+
let checkUrl = styles.sources[sourceName].url || styles.sources[sourceName].tiles[0];
|
|
5249
|
+
if (checkUrl && !CommonUtil.isAbsoluteURL(checkUrl)) {
|
|
5250
|
+
checkUrl = CommonUtil.relative2absolute(checkUrl, baseUrl);
|
|
5251
|
+
}
|
|
5252
|
+
const withCredentials = CommonUtil.isInTheSameDomain(checkUrl) || this.isIportalProxyServiceUrl(checkUrl);
|
|
5253
|
+
const requestParameters = this.tileRequestParameters && this.tileRequestParameters(checkUrl);
|
|
5079
5254
|
// 创建MapBoxStyle样式
|
|
5080
5255
|
let mapboxStyles = new MapboxStyles({
|
|
5256
|
+
baseUrl,
|
|
5081
5257
|
style: styles,
|
|
5082
5258
|
source: styles.name,
|
|
5083
5259
|
resolutions: styleResolutions,
|
|
5084
5260
|
map: this.map,
|
|
5085
|
-
withCredentials
|
|
5261
|
+
withCredentials,
|
|
5262
|
+
...requestParameters
|
|
5086
5263
|
});
|
|
5087
5264
|
return new Promise((resolve) => {
|
|
5088
5265
|
mapboxStyles.on('styleloaded', function () {
|
|
@@ -5092,13 +5269,15 @@ export class WebMap extends Observable {
|
|
|
5092
5269
|
//设置避让参数
|
|
5093
5270
|
declutter: true,
|
|
5094
5271
|
source: new VectorTileSuperMapRest({
|
|
5272
|
+
baseUrl,
|
|
5095
5273
|
style: styles,
|
|
5096
5274
|
withCredentials,
|
|
5097
5275
|
projection: layerInfo.projection,
|
|
5098
5276
|
format: new MVT({
|
|
5099
5277
|
featureClass: olRenderFeature
|
|
5100
5278
|
}),
|
|
5101
|
-
wrapX: false
|
|
5279
|
+
wrapX: false,
|
|
5280
|
+
...requestParameters
|
|
5102
5281
|
}),
|
|
5103
5282
|
style: mapboxStyles.featureStyleFuntion,
|
|
5104
5283
|
visible: layerInfo.visible,
|
|
@@ -5119,9 +5298,10 @@ export class WebMap extends Observable {
|
|
|
5119
5298
|
* @description 判断是否支持webP
|
|
5120
5299
|
* @param {*} url 服务地址
|
|
5121
5300
|
* @param {*} token 服务token
|
|
5301
|
+
* @param {*} proxy
|
|
5122
5302
|
* @returns {boolean}
|
|
5123
5303
|
*/
|
|
5124
|
-
isSupportWebp(url, token) {
|
|
5304
|
+
isSupportWebp(url, token, proxy) {
|
|
5125
5305
|
// 还需要判断浏览器
|
|
5126
5306
|
let isIE = this.isIE();
|
|
5127
5307
|
if (
|
|
@@ -5132,17 +5312,9 @@ export class WebMap extends Observable {
|
|
|
5132
5312
|
return false;
|
|
5133
5313
|
}
|
|
5134
5314
|
url = token ? `${url}/tileImage.webp?token=${token}` : `${url}/tileImage.webp`;
|
|
5135
|
-
|
|
5136
|
-
excledeCreditial;
|
|
5137
|
-
if (isSameDomain && !token) {
|
|
5138
|
-
// online上服务域名一直,要用token值
|
|
5139
|
-
excledeCreditial = false;
|
|
5140
|
-
} else {
|
|
5141
|
-
excledeCreditial = true;
|
|
5142
|
-
}
|
|
5143
|
-
url = this.getRequestUrl(url, excledeCreditial);
|
|
5315
|
+
url = this.getRequestUrl(url, proxy);
|
|
5144
5316
|
return FetchRequest.get(url, null, {
|
|
5145
|
-
withCredentials: this.
|
|
5317
|
+
withCredentials: this.isCredentail(url, proxy),
|
|
5146
5318
|
withoutFormatSuffix: true
|
|
5147
5319
|
})
|
|
5148
5320
|
.then(function (response) {
|