@supermapgis/iclient-ol 11.2.1 → 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.
Files changed (85) hide show
  1. package/control/ChangeTileVersion.js +1 -1
  2. package/control/Logo.js +1 -1
  3. package/control/ScaleLine.js +2 -3
  4. package/control/index.js +1 -1
  5. package/core/MapExtend.js +1 -1
  6. package/core/StyleUtils.js +3 -3
  7. package/core/Util.js +4 -20
  8. package/core/index.js +1 -1
  9. package/css/index.js +1 -1
  10. package/dist/iclient-openlayers-es6.js +25314 -16089
  11. package/dist/iclient-openlayers-es6.min.js +3 -3
  12. package/dist/iclient-openlayers.css +2 -2
  13. package/dist/iclient-openlayers.js +135928 -123450
  14. package/dist/iclient-openlayers.min.css +2 -2
  15. package/dist/iclient-openlayers.min.js +3 -3
  16. package/index.js +1 -1
  17. package/mapping/BaiduMap.js +1 -2
  18. package/mapping/ImageSuperMapRest.js +68 -12
  19. package/mapping/ImageTileSuperMapRest.js +1 -1
  20. package/mapping/SuperMapCloud.js +1 -1
  21. package/mapping/Tianditu.js +1 -1
  22. package/mapping/TileSuperMapRest.js +1 -1
  23. package/mapping/WebMap.js +321 -166
  24. package/mapping/index.js +1 -1
  25. package/namespace.js +1 -1
  26. package/overlay/DataFlow.js +1 -1
  27. package/overlay/FGB.js +69 -4
  28. package/overlay/Graph.js +1 -1
  29. package/overlay/GraphMap.js +1 -1
  30. package/overlay/Graphic.js +1 -1
  31. package/overlay/HeatMap.js +1 -1
  32. package/overlay/Label.js +1 -1
  33. package/overlay/Mapv.js +1 -1
  34. package/overlay/Range.js +1 -1
  35. package/overlay/RankSymbol.js +1 -1
  36. package/overlay/Turf.js +1 -1
  37. package/overlay/Unique.js +1 -1
  38. package/overlay/VectorTileSuperMapRest.js +120 -87
  39. package/overlay/graphic/CanvasRenderer.js +1 -1
  40. package/overlay/graphic/CloverShape.js +1 -1
  41. package/overlay/graphic/Graphic.js +1 -1
  42. package/overlay/graphic/HitCloverShape.js +1 -1
  43. package/overlay/graphic/WebGLRenderer.js +1 -1
  44. package/overlay/graphic/index.js +1 -1
  45. package/overlay/index.js +1 -1
  46. package/overlay/mapv/MapvCanvasLayer.js +1 -1
  47. package/overlay/mapv/MapvLayer.js +1 -1
  48. package/overlay/mapv/index.js +1 -1
  49. package/overlay/theme/GeoFeature.js +1 -1
  50. package/overlay/theme/Theme.js +1 -1
  51. package/overlay/theme/ThemeFeature.js +1 -1
  52. package/overlay/theme/index.js +1 -1
  53. package/overlay/vectortile/DeafultCanvasStyle.js +1 -1
  54. package/overlay/vectortile/MapboxStyles.js +428 -389
  55. package/overlay/vectortile/StyleMap.js +1 -1
  56. package/overlay/vectortile/VectorTileStyles.js +1 -1
  57. package/overlay/vectortile/index.js +1 -1
  58. package/overlay/vectortile/olExtends.js +1 -1
  59. package/package.json +7 -7
  60. package/services/AddressMatchService.js +1 -1
  61. package/services/ChartService.js +1 -1
  62. package/services/DataFlowService.js +1 -1
  63. package/services/DatasetService.js +1 -1
  64. package/services/DatasourceService.js +1 -1
  65. package/services/FeatureService.js +1 -1
  66. package/services/FieldService.js +1 -1
  67. package/services/GridCellInfosService.js +1 -1
  68. package/services/ImageCollectionService.js +1 -1
  69. package/services/ImageService.js +1 -1
  70. package/services/KnowledgeGraphService.js +1 -1
  71. package/services/LayerInfoService.js +1 -1
  72. package/services/MapService.js +1 -1
  73. package/services/MeasureService.js +1 -1
  74. package/services/NetworkAnalyst3DService.js +1 -1
  75. package/services/NetworkAnalystService.js +1 -1
  76. package/services/ProcessingService.js +1 -1
  77. package/services/QueryService.js +1 -1
  78. package/services/ServiceBase.js +1 -1
  79. package/services/SpatialAnalystService.js +1 -1
  80. package/services/ThemeService.js +1 -1
  81. package/services/TrafficTransferAnalystService.js +1 -1
  82. package/services/WebPrintingJobService.js +1 -1
  83. package/services/index.js +1 -1
  84. package/mapping/webmap/config/MunicipalCenter.json +0 -1
  85. package/mapping/webmap/config/ProvinceCenter.json +0 -1
package/mapping/WebMap.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
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';
@@ -9,15 +9,15 @@ import { SecurityManager } from '@supermapgis/iclient-common/security/SecurityMa
9
9
  import { Events } from '@supermapgis/iclient-common/commontypes/Events';
10
10
  import { Util as CommonUtil } from '@supermapgis/iclient-common/commontypes/Util';
11
11
  import { parseCondition, parseConditionFeature } from '@supermapgis/iclient-common/util/FilterCondition';
12
+ import { createLinesData } from '@supermapgis/iclient-common/mapping/utils/util';
12
13
  import { Util } from '../core/Util';
13
14
  import { getFeatureBySQL, queryFeatureBySQL, getFeatureProperties } from './webmap/Util';
14
15
  import { StyleUtils } from '../core/StyleUtils';
15
16
  import { TileSuperMapRest, Tianditu, BaiduMap } from '../mapping';
16
17
  import { VectorTileSuperMapRest, Graphic as GraphicSource, MapboxStyles, OverlayGraphic } from '../overlay';
17
18
  import { DataFlowService } from '../services';
19
+ import cloneDeep from 'lodash.clonedeep';
18
20
 
19
- import provincialCenterData from './webmap/config/ProvinceCenter.json'; // eslint-disable-line import/extensions
20
- import municipalCenterData from './webmap/config/MunicipalCenter.json'; // eslint-disable-line import/extensions
21
21
  import SampleDataInfo from './webmap/config/SampleDataInfo.json'; // eslint-disable-line import/extensions
22
22
 
23
23
  import GeoJSON from 'ol/format/GeoJSON';
@@ -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
- * @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
87
- * @param {boolean} [options.excludePortalProxyUrl] - server 传递过来的 URL 是否带有代理。
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.excludePortalProxyUrl && this.server.indexOf(filter) > -1) {
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: this.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.withCredentials,
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: this.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 && !CommonUtil.isInTheSameDomain(url) && !this.isIportalProxyServiceUrl(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, true), null, {
608
- withCredentials: this.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({}, this.map.getView().options_, {
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 (options.baseLayer && extent && extent.length === 4) {
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
  ) {
@@ -968,6 +982,9 @@ export class WebMap extends Observable {
968
982
  case 'SUPERMAP_REST':
969
983
  source = that.createDynamicTiledSource(layerInfo, isBaseLayer);
970
984
  break;
985
+ case 'ZXY_TILE':
986
+ source = this.createXYZTileSource(layerInfo);
987
+ break;
971
988
  case 'CLOUD':
972
989
  case 'CLOUD_BLACK':
973
990
  case 'OSM':
@@ -985,7 +1002,8 @@ export class WebMap extends Observable {
985
1002
  var layer = new olLayer.Tile({
986
1003
  source: source,
987
1004
  zIndex: layerInfo.zIndex || 1,
988
- visible: layerInfo.visible
1005
+ visible: layerInfo.visible,
1006
+ ...this.getLayerOtherOptions(layerInfo)
989
1007
  });
990
1008
  var layerID = Util.newGuid(8);
991
1009
  if (layerInfo.name) {
@@ -1173,6 +1191,42 @@ export class WebMap extends Observable {
1173
1191
  break;
1174
1192
  }
1175
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
+
1176
1230
  /**
1177
1231
  * @private
1178
1232
  * @function WebMap.prototype.createDynamicTiledSource
@@ -1203,7 +1257,8 @@ export class WebMap extends Observable {
1203
1257
  // crossOrigin: 'anonymous', //在IE11.0.9600版本,会影响通过注册服务打开的iserver地图,不出图。因为没有携带cookie会报跨域问题
1204
1258
  // extent: this.baseLayerExtent,
1205
1259
  // prjCoordSys: {epsgCode: isBaseLayer ? layerInfo.projection.split(':')[1] : this.baseProjection.split(':')[1]},
1206
- format: layerInfo.format
1260
+ format: layerInfo.format,
1261
+ tileLoadFunction: this.getCustomTileLoadFunction()
1207
1262
  };
1208
1263
  if (!isBaseLayer && !this.isCustomProjection(this.baseProjection)) {
1209
1264
  options.prjCoordSys = { epsgCode: this.baseProjection.split(':')[1] };
@@ -1232,9 +1287,8 @@ export class WebMap extends Observable {
1232
1287
  //主机名相同时不添加代理,iportal geturlResource不支持webp代理
1233
1288
  if (
1234
1289
  layerInfo.url &&
1235
- !CommonUtil.isInTheSameDomain(layerInfo.url) &&
1236
- !this.isIportalProxyServiceUrl(layerInfo.url) &&
1237
- layerInfo.format !== 'webp'
1290
+ layerInfo.format !== 'webp' &&
1291
+ this.isAddProxy(layerInfo.url, layerInfo.proxy)
1238
1292
  ) {
1239
1293
  options.tileProxy = this.server + 'apps/viewer/getUrlResource.png?url=';
1240
1294
  }
@@ -1317,10 +1371,67 @@ export class WebMap extends Observable {
1317
1371
  return new XYZ({
1318
1372
  url: layerInfo.url,
1319
1373
  wrapX: false,
1320
- crossOrigin: 'anonymous'
1374
+ crossOrigin: 'anonymous',
1375
+ tileLoadFunction: this.getCustomTileLoadFunction()
1321
1376
  });
1322
1377
  }
1323
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
+ }
1406
+ /**
1407
+ * @private
1408
+ * @function WebMap.prototype.createXYZTileSource
1409
+ * @description 创建图层的XYZTilesource。
1410
+ * @param {Object} layerInfo - 图层信息
1411
+ * @returns {ol.source.XYZ} xyz的source
1412
+ */
1413
+ createXYZTileSource(layerInfo) {
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 = {
1417
+ urls,
1418
+ wrapX: false,
1419
+ crossOrigin: 'anonymous',
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
+ }
1434
+ }
1324
1435
  /**
1325
1436
  * @private
1326
1437
  * @function WebMap.prototype.createWMSSource
@@ -1339,9 +1450,9 @@ export class WebMap extends Observable {
1339
1450
  VERSION: layerInfo.version || '1.3.0'
1340
1451
  },
1341
1452
  projection: layerInfo.projection || that.baseProjection,
1342
- tileLoadFunction: function (imageTile, src) {
1343
- imageTile.getImage().src = src;
1344
- }
1453
+ tileLoadFunction: this.getCustomTileLoadFunction((src) => {
1454
+ return that.isAddProxy(src, layerInfo.proxy) ? `${that.getProxy('png')}${encodeURIComponent(src)}`: src;
1455
+ })
1345
1456
  });
1346
1457
  }
1347
1458
 
@@ -1389,7 +1500,7 @@ export class WebMap extends Observable {
1389
1500
  url = layerInfo.url.trim(),
1390
1501
  credential = layerInfo.credential,
1391
1502
  options = {
1392
- withCredentials: this.withCredentials,
1503
+ withCredentials: that.isCredentail(url, layerInfo.proxy),
1393
1504
  withoutFormatSuffix: true
1394
1505
  };
1395
1506
  if (isDynamic) {
@@ -1406,7 +1517,7 @@ export class WebMap extends Observable {
1406
1517
  token = credential.token;
1407
1518
  }
1408
1519
  url = this.handleJSONSuffix(url);
1409
- return FetchRequest.get(that.getRequestUrl(url), null, options)
1520
+ return FetchRequest.get(that.getRequestUrl(url, layerInfo.proxy), null, options)
1410
1521
  .then(function (response) {
1411
1522
  return response.json();
1412
1523
  })
@@ -1416,7 +1527,7 @@ export class WebMap extends Observable {
1416
1527
  }
1417
1528
  let format = 'png';
1418
1529
  if (that.tileFormat === 'webp') {
1419
- const isSupportWebp = await that.isSupportWebp(layerInfo.url, token);
1530
+ const isSupportWebp = await that.isSupportWebp(layerInfo.url, token, layerInfo.proxy);
1420
1531
  format = isSupportWebp ? 'webp' : 'png';
1421
1532
  }
1422
1533
  return {
@@ -1446,7 +1557,7 @@ export class WebMap extends Observable {
1446
1557
  getTileInfo(layerInfo, callback, mapInfo) {
1447
1558
  let that = this;
1448
1559
  let options = {
1449
- withCredentials: this.withCredentials,
1560
+ withCredentials: that.isCredentail(layerInfo.url, layerInfo.proxy),
1450
1561
  withoutFormatSuffix: true
1451
1562
  };
1452
1563
  let tempUrl = layerInfo.url;
@@ -1455,7 +1566,7 @@ export class WebMap extends Observable {
1455
1566
  layerInfo.url = layerInfo.url.split('?token=')[0];
1456
1567
  }
1457
1568
  let url = this.handleJSONSuffix(tempUrl);
1458
- return FetchRequest.get(that.getRequestUrl(url), null, options)
1569
+ return FetchRequest.get(that.getRequestUrl(url, layerInfo.proxy), null, options)
1459
1570
  .then(function (response) {
1460
1571
  return response.json();
1461
1572
  })
@@ -1479,7 +1590,7 @@ export class WebMap extends Observable {
1479
1590
  that.tileFormat === 'webp' &&
1480
1591
  layerInfo.url !== 'https://maptiles.supermapol.com/iserver/services/map_China/rest/maps/China_Dark'
1481
1592
  ) {
1482
- const isSupprtWebp = await that.isSupportWebp(layerInfo.url, token);
1593
+ const isSupprtWebp = await that.isSupportWebp(layerInfo.url, token, layerInfo.proxy);
1483
1594
  layerInfo.format = isSupprtWebp ? 'webp' : 'png';
1484
1595
  }
1485
1596
  // 请求结果完成 继续添加图层
@@ -1500,8 +1611,9 @@ export class WebMap extends Observable {
1500
1611
  * @description 获取wmts请求文档的url
1501
1612
  * @param {string} url - 图层信息。
1502
1613
  * @param {boolean} isKvp - 是否为kvp模式
1614
+ * @param {boolean} proxy - 是否带上代理地址
1503
1615
  */
1504
- getWMTSUrl(url, isKvp) {
1616
+ getWMTSUrl(url, isKvp, proxy) {
1505
1617
  let splitStr = '?';
1506
1618
  if (url.indexOf('?') > -1) {
1507
1619
  splitStr = '&';
@@ -1511,7 +1623,7 @@ export class WebMap extends Observable {
1511
1623
  } else {
1512
1624
  url += splitStr + '/1.0.0/WMTSCapabilities.xml';
1513
1625
  }
1514
- return this.getRequestUrl(url, true);
1626
+ return this.getRequestUrl(url, proxy);
1515
1627
  }
1516
1628
 
1517
1629
  /**
@@ -1524,11 +1636,11 @@ export class WebMap extends Observable {
1524
1636
  getWmtsInfo(layerInfo, callback) {
1525
1637
  let that = this;
1526
1638
  let options = {
1527
- withCredentials: that.withCredentials,
1639
+ withCredentials: that.isCredentail(layerInfo.url, layerInfo.proxy),
1528
1640
  withoutFormatSuffix: true
1529
1641
  };
1530
1642
  const isKvp = !layerInfo.requestEncoding || layerInfo.requestEncoding === 'KVP';
1531
- return FetchRequest.get(that.getWMTSUrl(layerInfo.url, isKvp), null, options)
1643
+ return FetchRequest.get(that.getWMTSUrl(layerInfo.url, isKvp, layerInfo.proxy), null, options)
1532
1644
  .then(function (response) {
1533
1645
  return response.text();
1534
1646
  })
@@ -1631,12 +1743,12 @@ export class WebMap extends Observable {
1631
1743
  let url = layerInfo.url.trim();
1632
1744
  url += url.indexOf('?') > -1 ? '&SERVICE=WMS&REQUEST=GetCapabilities' : '?SERVICE=WMS&REQUEST=GetCapabilities';
1633
1745
  let options = {
1634
- withCredentials: that.withCredentials,
1746
+ withCredentials: that.isCredentail(url, layerInfo.proxy),
1635
1747
  withoutFormatSuffix: true
1636
1748
  };
1637
1749
 
1638
1750
  let promise = new Promise(function (resolve) {
1639
- return FetchRequest.get(that.getRequestUrl(url, true), null, options)
1751
+ return FetchRequest.get(that.getRequestUrl(url, layerInfo.proxy), null, options)
1640
1752
  .then(function (response) {
1641
1753
  return response.text();
1642
1754
  })
@@ -1718,7 +1830,7 @@ export class WebMap extends Observable {
1718
1830
 
1719
1831
  // 单位通过坐标系获取 (PS: 以前代码非4326 都默认是米)
1720
1832
  let unit = olProj.get(this.baseProjection).getUnits();
1721
-
1833
+ const that = this;
1722
1834
  return new WMTS({
1723
1835
  url: layerInfo.tileUrl || layerInfo.url,
1724
1836
  layer: layerInfo.layer,
@@ -1734,13 +1846,15 @@ export class WebMap extends Observable {
1734
1846
  layerInfo.origin,
1735
1847
  layerInfo.matrixIds
1736
1848
  ),
1737
- tileLoadFunction: function (imageTile, src) {
1849
+ tileLoadFunction: this.getCustomTileLoadFunction(function (src) {
1738
1850
  if (src.indexOf('tianditu.gov.cn') >= 0) {
1739
- imageTile.getImage().src = `${src}&tk=${CommonUtil.getParameters(layerInfo.url)['tk']}`;
1740
- return;
1851
+ return `${src}&tk=${CommonUtil.getParameters(layerInfo.url)['tk']}`;
1741
1852
  }
1742
- imageTile.getImage().src = src;
1743
- }
1853
+ if(that.isAddProxy(src, layerInfo.proxy)) {
1854
+ return `${that.getProxy('png')}${encodeURIComponent(src)}`;
1855
+ }
1856
+ return src;
1857
+ })
1744
1858
  });
1745
1859
  }
1746
1860
 
@@ -1891,7 +2005,7 @@ export class WebMap extends Observable {
1891
2005
  await that.addLayer(layer, null, layerIndex);
1892
2006
  that.layerAdded++;
1893
2007
  that.sendMapToUser(len);
1894
- return;
2008
+ continue;
1895
2009
  }
1896
2010
  if (
1897
2011
  layer.layerType === 'MARKER' ||
@@ -1902,9 +2016,9 @@ export class WebMap extends Observable {
1902
2016
  let url = isSampleData
1903
2017
  ? `${that.server}apps/dataviz/libs/sample-datas/${dataSource.name}.json`
1904
2018
  : `${that.server}web/datas/${serverId}/content.json?pageSize=9999999&currentPage=1`;
1905
- url = that.getRequestUrl(url);
2019
+ url = that.getRequestUrl(url, layer.proxy);
1906
2020
  FetchRequest.get(url, null, {
1907
- withCredentials: this.withCredentials
2021
+ withCredentials: that.isCredentail(url, layer.proxy)
1908
2022
  })
1909
2023
  .then(function (response) {
1910
2024
  return response.json();
@@ -1926,7 +2040,7 @@ export class WebMap extends Observable {
1926
2040
  //行政规划信息
1927
2041
  data.content.rows.unshift(data.content.colTitles);
1928
2042
  let { divisionType, divisionField } = layer.dataSource.administrativeInfo;
1929
- let geojson = that.excelData2FeatureByDivision(data.content, divisionType, divisionField);
2043
+ let geojson = await that.excelData2FeatureByDivision(data.content, divisionType, divisionField);
1930
2044
  features = that._parseGeoJsonData2Feature({
1931
2045
  allDatas: { features: geojson.features },
1932
2046
  fileCode: layer.projection
@@ -1971,7 +2085,7 @@ export class WebMap extends Observable {
1971
2085
  //需要判断是使用tile还是mvt服务
1972
2086
  let dataService = that.getService(dataItemServices, 'RESTDATA');
1973
2087
  that
1974
- .isMvt(dataService.address, datasetName)
2088
+ .isMvt(dataService.address, datasetName, layer.proxy)
1975
2089
  .then(async (info) => {
1976
2090
  await that.getServiceInfoFromLayer(
1977
2091
  layerIndex,
@@ -2018,7 +2132,7 @@ export class WebMap extends Observable {
2018
2132
  });
2019
2133
  }
2020
2134
  } else if (dataSource && dataSource.type === 'USER_DATA') {
2021
- that.addGeojsonFromUrl(layer, len, layerIndex, false);
2135
+ that.addGeojsonFromUrl(layer, len, layerIndex);
2022
2136
  } else if (layer.layerType === 'TILE') {
2023
2137
  that.getTileLayerExtent(
2024
2138
  layer,
@@ -2107,6 +2221,10 @@ export class WebMap extends Observable {
2107
2221
  that.errorCallback && that.errorCallback(e, 'getFeatureFaild', that.map);
2108
2222
  }
2109
2223
  );
2224
+ } else if (layer.layerType === 'ZXY_TILE') {
2225
+ that.map.addLayer(that.createBaseLayer(layer, layerIndex));
2226
+ that.layerAdded++;
2227
+ that.sendMapToUser(len);
2110
2228
  }
2111
2229
  }
2112
2230
  }
@@ -2118,15 +2236,14 @@ export class WebMap extends Observable {
2118
2236
  * @param {Object} layerInfo - 图层信息
2119
2237
  * @param {number} len - 总的图层数量
2120
2238
  * @param {number} layerIndex - 当前图层index
2121
- * @param {boolean} withCredentials - 是否携带cookie
2122
2239
  */
2123
- addGeojsonFromUrl(layerInfo, len, layerIndex, withCredentials = this.withCredentials) {
2240
+ addGeojsonFromUrl(layerInfo, len, layerIndex) {
2124
2241
  // 通过web添加geojson不需要携带cookie
2125
2242
  let { dataSource } = layerInfo,
2126
2243
  { url } = dataSource,
2127
2244
  that = this;
2128
2245
  FetchRequest.get(url, null, {
2129
- withCredentials,
2246
+ withCredentials: that.isCredentail(url),
2130
2247
  withoutFormatSuffix: true
2131
2248
  })
2132
2249
  .then(function (response) {
@@ -2205,7 +2322,7 @@ export class WebMap extends Observable {
2205
2322
  if (service && isMapService && service.serviceType === 'RESTMAP') {
2206
2323
  isAdded = true;
2207
2324
  //地图服务,判断使用mvt还是tile
2208
- that.getTileLayerInfo(service.address).then(function (restMaps) {
2325
+ that.getTileLayerInfo(service.address, layer.proxy).then(function (restMaps) {
2209
2326
  restMaps.forEach(function (restMapInfo) {
2210
2327
  let bounds = restMapInfo.bounds;
2211
2328
  layer.layerType = 'TILE';
@@ -2272,13 +2389,13 @@ export class WebMap extends Observable {
2272
2389
  let url = layerInfo.url,
2273
2390
  token;
2274
2391
  url = this.handleJSONSuffix(url);
2275
- let requestUrl = that.getRequestUrl(url, false);
2392
+ let requestUrl = that.getRequestUrl(url, layerInfo.proxy);
2276
2393
  if (layerInfo.credential && layerInfo.credential.token) {
2277
2394
  token = layerInfo.credential.token;
2278
2395
  requestUrl += `?token=${token}`;
2279
2396
  }
2280
2397
  FetchRequest.get(requestUrl, null, {
2281
- withCredentials: this.withCredentials
2398
+ withCredentials: that.isCredentail(url, layerInfo.proxy)
2282
2399
  })
2283
2400
  .then(function (response) {
2284
2401
  return response.json();
@@ -2311,11 +2428,9 @@ export class WebMap extends Observable {
2311
2428
  dataSourceName = dataSource.dataSourceName || layer.name;
2312
2429
  let requestUrl = that.formatUrlWithCredential(url),
2313
2430
  serviceOptions = {};
2314
- serviceOptions.withCredentials = this.withCredentials;
2431
+ serviceOptions.withCredentials = this.isCredentail(url, layer.proxy);
2315
2432
  if (
2316
- !this.excludePortalProxyUrl &&
2317
- !CommonUtil.isInTheSameDomain(requestUrl) &&
2318
- !this.isIportalProxyServiceUrl(requestUrl)
2433
+ that.isAddProxy(requestUrl, layer.proxy)
2319
2434
  ) {
2320
2435
  serviceOptions.proxy = this.getProxy();
2321
2436
  }
@@ -2437,8 +2552,9 @@ export class WebMap extends Observable {
2437
2552
  if (layerInfo.layerType === 'MIGRATION') {
2438
2553
  try {
2439
2554
  if (dataSource.type === 'PORTAL_DATA') {
2440
- const { dataMetaInfo } = await FetchRequest.get(`${this.server}web/datas/${dataSource.serverId}.json`, null, {
2441
- withCredentials: this.withCredentials
2555
+ const requestUrl = `${this.server}web/datas/${dataSource.serverId}.json`;
2556
+ const { dataMetaInfo } = await FetchRequest.get(requestUrl, null, {
2557
+ withCredentials: this.isCredentail(requestUrl)
2442
2558
  }).then((res) => res.json());
2443
2559
  // eslint-disable-next-line require-atomic-updates
2444
2560
  layerInfo.xyField = {
@@ -2512,7 +2628,7 @@ export class WebMap extends Observable {
2512
2628
  * @returns {Object} geojson对象
2513
2629
  */
2514
2630
  excelData2FeatureByDivision(content, divisionType, divisionField) {
2515
- let me = this;
2631
+
2516
2632
  let asyncInport;
2517
2633
  if (divisionType === 'Province') {
2518
2634
  asyncInport = window.ProvinceData;
@@ -2522,10 +2638,33 @@ export class WebMap extends Observable {
2522
2638
  // let geojso;
2523
2639
  asyncInport = window.AdministrativeArea;
2524
2640
  }
2525
- if (asyncInport) {
2526
- let geojson = me.changeExcel2Geojson(asyncInport.features, content.rows, divisionType, divisionField);
2527
- return geojson;
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
+ });
2528
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
+ });
2529
2668
  }
2530
2669
 
2531
2670
  /**
@@ -2581,12 +2720,15 @@ export class WebMap extends Observable {
2581
2720
  }
2582
2721
  //todo 需提示忽略无效数据
2583
2722
  if (feature) {
2584
- let newFeature = window.cloneDeep(feature);
2723
+ let newFeature = (window.cloneDeep || cloneDeep)(feature);
2585
2724
  newFeature.properties = {};
2725
+ const titleLen = titles.length;
2586
2726
  row.forEach((item, idx) => {
2587
2727
  //空格问题,看见DV多处处理空格问题,TODO统一整理
2588
- let key = titles[idx].trim();
2589
- newFeature.properties[key] = item;
2728
+ if (idx < titleLen) {
2729
+ let key = titles[idx].trim();
2730
+ newFeature.properties[key] = item;
2731
+ }
2590
2732
  });
2591
2733
  geojson.features.push(newFeature);
2592
2734
  }
@@ -2617,6 +2759,7 @@ export class WebMap extends Observable {
2617
2759
  if (allFeatures[i].geometry.type === 'Point') {
2618
2760
  // 标注图层 还没有属性值时候不加
2619
2761
  if (allFeatures[i].properties) {
2762
+
2620
2763
  allFeatures[i].properties.lon = coordinate[0];
2621
2764
  allFeatures[i].properties.lat = coordinate[1];
2622
2765
  }
@@ -2845,11 +2988,9 @@ export class WebMap extends Observable {
2845
2988
  } else {
2846
2989
  let requestUrl = that.formatUrlWithCredential(url),
2847
2990
  serviceOptions = {};
2848
- serviceOptions.withCredentials = this.withCredentials;
2991
+ serviceOptions.withCredentials = that.isCredentail(requestUrl);
2849
2992
  if (
2850
- !this.excludePortalProxyUrl &&
2851
- !CommonUtil.isInTheSameDomain(requestUrl) &&
2852
- !this.isIportalProxyServiceUrl(requestUrl)
2993
+ that.isAddProxy(requestUrl)
2853
2994
  ) {
2854
2995
  serviceOptions.proxy = this.getProxy();
2855
2996
  }
@@ -2931,13 +3072,15 @@ export class WebMap extends Observable {
2931
3072
  };
2932
3073
  let featureType = layerInfo.featureType;
2933
3074
  let style = await StyleUtils.toOpenLayersStyle(this.getDataVectorTileStyle(featureType), featureType);
3075
+ const requestParameters = this.tileRequestParameters && this.tileRequestParameters(layerInfo.url);
2934
3076
  return new olLayer.VectorTile({
2935
3077
  //设置避让参数
2936
3078
  source: new VectorTileSuperMapRest({
2937
3079
  url: layerInfo.url,
2938
3080
  projection: layerInfo.projection,
2939
3081
  tileType: 'ScaleXY',
2940
- format: format
3082
+ format: format,
3083
+ ...requestParameters
2941
3084
  }),
2942
3085
  style: style
2943
3086
  });
@@ -4173,7 +4316,7 @@ export class WebMap extends Observable {
4173
4316
  checkUploadToRelationship(fileId) {
4174
4317
  let url = this.getRequestUrl(`${this.server}web/datas/${fileId}/datasets.json`);
4175
4318
  return FetchRequest.get(url, null, {
4176
- withCredentials: this.withCredentials
4319
+ withCredentials: this.isCredentail(url)
4177
4320
  })
4178
4321
  .then(function (response) {
4179
4322
  return response.json();
@@ -4192,7 +4335,7 @@ export class WebMap extends Observable {
4192
4335
  getDatasources(url) {
4193
4336
  let requestUrl = this.getRequestUrl(`${url}/data/datasources.json`);
4194
4337
  return FetchRequest.get(requestUrl, null, {
4195
- withCredentials: this.withCredentials
4338
+ withCredentials: this.isCredentail(requestUrl)
4196
4339
  })
4197
4340
  .then(function (response) {
4198
4341
  return response.json();
@@ -4213,7 +4356,7 @@ export class WebMap extends Observable {
4213
4356
  getDataService(fileId, datasetName) {
4214
4357
  let url = this.getRequestUrl(`${this.server}web/datas/${fileId}.json`);
4215
4358
  return FetchRequest.get(url, null, {
4216
- withCredentials: this.withCredentials
4359
+ withCredentials: this.isCredentail(url)
4217
4360
  })
4218
4361
  .then(function (response) {
4219
4362
  return response.json();
@@ -4225,23 +4368,41 @@ export class WebMap extends Observable {
4225
4368
  });
4226
4369
  }
4227
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
+
4228
4393
  /**
4229
4394
  * @private
4230
4395
  * @function WebMap.prototype.getRootUrl
4231
4396
  * @description 获取请求地址。
4232
4397
  * @param {string} url 请求的地址。
4233
- * @param {boolean} 请求是否带上Credential。
4398
+ * @param {boolean | undefined} proxy 是否带上代理。
4234
4399
  * @returns {Promise<T | never>} 请求地址。
4235
4400
  */
4236
- getRequestUrl(url, excludeCreditial) {
4237
- url = excludeCreditial ? url : this.formatUrlWithCredential(url);
4238
- //如果传入进来的url带了代理则不需要处理
4239
- if (this.excludePortalProxyUrl) {
4240
- return;
4241
- }
4242
- return CommonUtil.isInTheSameDomain(url) || this.isIportalProxyServiceUrl(url)
4243
- ? url
4244
- : `${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
4245
4406
  }
4246
4407
 
4247
4408
  /**
@@ -4277,14 +4438,15 @@ export class WebMap extends Observable {
4277
4438
  * @function WebMap.prototype.getTileLayerInfo
4278
4439
  * @description 获取地图服务的信息
4279
4440
  * @param {string} url 地图服务的url(没有地图名字)
4441
+ * @param {boolean | undefined} proxy 是否需要代理
4280
4442
  * @returns {Promise<T | never>} 地图服务信息
4281
4443
  */
4282
- getTileLayerInfo(url) {
4444
+ getTileLayerInfo(url, proxy) {
4283
4445
  let that = this,
4284
4446
  epsgCode = that.baseProjection.split('EPSG:')[1];
4285
- let requestUrl = that.getRequestUrl(`${url}/maps.json`);
4447
+ let requestUrl = that.getRequestUrl(`${url}/maps.json`, proxy);
4286
4448
  return FetchRequest.get(requestUrl, null, {
4287
- withCredentials: this.withCredentials
4449
+ withCredentials: this.isCredentail(url, proxy)
4288
4450
  })
4289
4451
  .then(function (response) {
4290
4452
  return response.json();
@@ -4294,10 +4456,11 @@ export class WebMap extends Observable {
4294
4456
  if (mapInfo) {
4295
4457
  mapInfo.forEach(function (info) {
4296
4458
  let mapUrl = that.getRequestUrl(
4297
- `${info.path}.json?prjCoordSys=${encodeURI(JSON.stringify({ epsgCode: epsgCode }))}`
4459
+ `${info.path}.json?prjCoordSys=${encodeURI(JSON.stringify({ epsgCode: epsgCode }))}`,
4460
+ proxy
4298
4461
  );
4299
4462
  let promise = FetchRequest.get(mapUrl, null, {
4300
- withCredentials: that.withCredentials
4463
+ withCredentials: that.isCredentail(mapUrl, proxy)
4301
4464
  })
4302
4465
  .then(function (response) {
4303
4466
  return response.json();
@@ -4617,51 +4780,7 @@ export class WebMap extends Observable {
4617
4780
  * @returns {Array} 线数据
4618
4781
  */
4619
4782
  createLinesData(layerInfo, properties) {
4620
- let data = [];
4621
- if (properties && properties.length) {
4622
- // 重新获取数据
4623
- let from = layerInfo.from,
4624
- to = layerInfo.to,
4625
- fromCoord,
4626
- toCoord;
4627
- if (from.type === 'XY_FIELD' && from['xField'] && from['yField'] && to['xField'] && to['yField']) {
4628
- properties.forEach((property) => {
4629
- let fromX = property[from['xField']],
4630
- fromY = property[from['yField']],
4631
- toX = property[to['xField']],
4632
- toY = property[to['yField']];
4633
- if (!fromX || !fromY || !toX || !toY) {
4634
- return;
4635
- }
4636
-
4637
- fromCoord = [property[from['xField']], property[from['yField']]];
4638
- toCoord = [property[to['xField']], property[to['yField']]];
4639
- data.push({
4640
- coords: [fromCoord, toCoord]
4641
- });
4642
- });
4643
- } else if (from.type === 'PLACE_FIELD' && from['field'] && to['field']) {
4644
- const centerDatas = provincialCenterData.concat(municipalCenterData);
4645
-
4646
- properties.forEach((property) => {
4647
- let fromField = property[from['field']],
4648
- toField = property[to['field']];
4649
- fromCoord = centerDatas.find((item) => {
4650
- return Util.isMatchAdministrativeName(item.name, fromField);
4651
- });
4652
- toCoord = centerDatas.find((item) => {
4653
- return Util.isMatchAdministrativeName(item.name, toField);
4654
- });
4655
- if (!fromCoord || !toCoord) {
4656
- return;
4657
- }
4658
- data.push({
4659
- coords: [fromCoord.coord, toCoord.coord]
4660
- });
4661
- });
4662
- }
4663
- }
4664
- return data;
4783
+ return createLinesData(layerInfo, properties);
4665
4784
  }
4666
4785
 
4667
4786
  /**
@@ -4685,15 +4804,16 @@ export class WebMap extends Observable {
4685
4804
  * @description 判断当前能否使用数据服务的mvt上图方式
4686
4805
  * @param {string} serviceUrl 数据服务的地址
4687
4806
  * @param {string} datasetName 数据服务的数据集名称
4807
+ * @param {boolean | undefined} proxy 是否带上代理
4688
4808
  * @returns {Object} 数据服务的信息
4689
4809
  */
4690
- isMvt(serviceUrl, datasetName) {
4810
+ isMvt(serviceUrl, datasetName, proxy) {
4691
4811
  let that = this;
4692
4812
  return this.getDatasetsInfo(serviceUrl, datasetName).then((info) => {
4693
4813
  //判断是否和底图坐标系一直
4694
4814
  if (info.epsgCode == that.baseProjection.split('EPSG:')[1]) {
4695
- return FetchRequest.get(that.getRequestUrl(`${info.url}/tilefeature.mvt`), null, {
4696
- withCredentials: that.withCredentials
4815
+ return FetchRequest.get(that.getRequestUrl(`${info.url}/tilefeature.mvt`, proxy), null, {
4816
+ withCredentials: that.isCredentail(info.url, proxy)
4697
4817
  })
4698
4818
  .then(function (response) {
4699
4819
  return response.json();
@@ -4724,7 +4844,7 @@ export class WebMap extends Observable {
4724
4844
  //判断mvt服务是否可用
4725
4845
  let url = `${serviceUrl}/data/datasources/${datasourceName}/datasets/${datasetName}.json`;
4726
4846
  return FetchRequest.get(that.getRequestUrl(url), null, {
4727
- withCredentials: that.withCredentials
4847
+ withCredentials: that.isCredentail(url)
4728
4848
  })
4729
4849
  .then(function (response) {
4730
4850
  return response.json();
@@ -4801,8 +4921,13 @@ export class WebMap extends Observable {
4801
4921
  let url = dataSource.url;
4802
4922
  if (this.isRestMapMapboxStyle(layerInfo)) {
4803
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);
4804
4930
  }
4805
- url = this.getRequestUrl(url + '.json');
4806
4931
 
4807
4932
  let credential = layerInfo.credential;
4808
4933
  let credentialValue, keyfix;
@@ -4814,7 +4939,7 @@ export class WebMap extends Observable {
4814
4939
  }
4815
4940
 
4816
4941
  return FetchRequest.get(url, null, {
4817
- withCredentials: this.withCredentials,
4942
+ withCredentials: this.isCredentail(url),
4818
4943
  withoutFormatSuffix: true,
4819
4944
  headers: {
4820
4945
  'Content-Type': 'application/json;chartset=uft-8'
@@ -4825,10 +4950,23 @@ export class WebMap extends Observable {
4825
4950
  })
4826
4951
  .then((result) => {
4827
4952
  layerInfo.visibleScales = result.visibleScales;
4828
- layerInfo.coordUnit = result.coordUnit;
4953
+ layerInfo.coordUnit = result.coordUnit || 'METER';
4829
4954
  layerInfo.scale = result.scale;
4830
- layerInfo.epsgCode = result.prjCoordSys.epsgCode;
4831
- 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
+ };
4832
4970
  return layerInfo;
4833
4971
  })
4834
4972
  .catch((error) => {
@@ -4849,7 +4987,7 @@ export class WebMap extends Observable {
4849
4987
  let _this = this;
4850
4988
  let url = layerInfo.url || layerInfo.dataSource.url;
4851
4989
  let styleUrl = url;
4852
- if (styleUrl.indexOf('/restjsr/') > -1) {
4990
+ if (styleUrl.indexOf('/restjsr/') > -1 && !/\/style\.json$/.test(url)) {
4853
4991
  styleUrl = `${styleUrl}/style.json`;
4854
4992
  }
4855
4993
  styleUrl = this.getRequestUrl(styleUrl);
@@ -4863,7 +5001,7 @@ export class WebMap extends Observable {
4863
5001
  }
4864
5002
 
4865
5003
  return FetchRequest.get(styleUrl, null, {
4866
- withCredentials: this.withCredentials,
5004
+ withCredentials: this.isCredentail(styleUrl),
4867
5005
  withoutFormatSuffix: true,
4868
5006
  headers: {
4869
5007
  'Content-Type': 'application/json;chartset=uft-8'
@@ -4882,7 +5020,8 @@ export class WebMap extends Observable {
4882
5020
  let sourcesNames = Object.keys(sources);
4883
5021
  sourcesNames.forEach(function (sourceName) {
4884
5022
  styles.sources[sourceName].tiles.forEach(function (tiles, i) {
4885
- styles.sources[sourceName].tiles[i] = `${tiles}?${keyfix}=${credentialValue}`;
5023
+ const splicing = tiles.includes('?') ? '&' : '?';
5024
+ styles.sources[sourceName].tiles[i] = `${tiles}${splicing}${keyfix}=${credentialValue}`;
4886
5025
  });
4887
5026
  });
4888
5027
  }
@@ -5080,7 +5219,6 @@ export class WebMap extends Observable {
5080
5219
  * @param {Object} layerInfo - 图层信息
5081
5220
  */
5082
5221
  createMVTLayer(layerInfo) {
5083
- // let that = this;
5084
5222
  let styles = layerInfo.styles;
5085
5223
  const indexbounds = styles && styles.metadata && styles.metadata.indexbounds;
5086
5224
  const visibleResolution = this.createVisibleResolution(
@@ -5092,14 +5230,36 @@ export class WebMap extends Observable {
5092
5230
  const envelope = this.getEnvelope(indexbounds, layerInfo.bounds);
5093
5231
  const styleResolutions = this.getStyleResolutions(envelope);
5094
5232
  // const origin = [envelope.left, envelope.top];
5095
- let withCredentials = this.isIportalProxyServiceUrl(styles.sprite);
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);
5096
5254
  // 创建MapBoxStyle样式
5097
5255
  let mapboxStyles = new MapboxStyles({
5256
+ baseUrl,
5098
5257
  style: styles,
5099
5258
  source: styles.name,
5100
5259
  resolutions: styleResolutions,
5101
5260
  map: this.map,
5102
- withCredentials
5261
+ withCredentials,
5262
+ ...requestParameters
5103
5263
  });
5104
5264
  return new Promise((resolve) => {
5105
5265
  mapboxStyles.on('styleloaded', function () {
@@ -5109,13 +5269,15 @@ export class WebMap extends Observable {
5109
5269
  //设置避让参数
5110
5270
  declutter: true,
5111
5271
  source: new VectorTileSuperMapRest({
5272
+ baseUrl,
5112
5273
  style: styles,
5113
5274
  withCredentials,
5114
5275
  projection: layerInfo.projection,
5115
5276
  format: new MVT({
5116
5277
  featureClass: olRenderFeature
5117
5278
  }),
5118
- wrapX: false
5279
+ wrapX: false,
5280
+ ...requestParameters
5119
5281
  }),
5120
5282
  style: mapboxStyles.featureStyleFuntion,
5121
5283
  visible: layerInfo.visible,
@@ -5136,9 +5298,10 @@ export class WebMap extends Observable {
5136
5298
  * @description 判断是否支持webP
5137
5299
  * @param {*} url 服务地址
5138
5300
  * @param {*} token 服务token
5301
+ * @param {*} proxy
5139
5302
  * @returns {boolean}
5140
5303
  */
5141
- isSupportWebp(url, token) {
5304
+ isSupportWebp(url, token, proxy) {
5142
5305
  // 还需要判断浏览器
5143
5306
  let isIE = this.isIE();
5144
5307
  if (
@@ -5149,17 +5312,9 @@ export class WebMap extends Observable {
5149
5312
  return false;
5150
5313
  }
5151
5314
  url = token ? `${url}/tileImage.webp?token=${token}` : `${url}/tileImage.webp`;
5152
- let isSameDomain = CommonUtil.isInTheSameDomain(url),
5153
- excledeCreditial;
5154
- if (isSameDomain && !token) {
5155
- // online上服务域名一直,要用token值
5156
- excledeCreditial = false;
5157
- } else {
5158
- excledeCreditial = true;
5159
- }
5160
- url = this.getRequestUrl(url, excledeCreditial);
5315
+ url = this.getRequestUrl(url, proxy);
5161
5316
  return FetchRequest.get(url, null, {
5162
- withCredentials: this.withCredentials,
5317
+ withCredentials: this.isCredentail(url, proxy),
5163
5318
  withoutFormatSuffix: true
5164
5319
  })
5165
5320
  .then(function (response) {