@supermapgis/iclient-ol 11.2.0
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/README.md +56 -0
- package/control/ChangeTileVersion.js +438 -0
- package/control/Logo.js +97 -0
- package/control/ScaleLine.js +164 -0
- package/control/index.js +6 -0
- package/core/MapExtend.js +49 -0
- package/core/StyleUtils.js +1253 -0
- package/core/Util.js +500 -0
- package/core/index.js +6 -0
- package/css/ChangeTileVersion.css +347 -0
- package/css/index.js +5 -0
- package/dist/iclient-openlayers-es6.js +124963 -0
- package/dist/iclient-openlayers-es6.min.js +8 -0
- package/dist/iclient-openlayers.css +668 -0
- package/dist/iclient-openlayers.js +142946 -0
- package/dist/iclient-openlayers.min.css +8 -0
- package/dist/iclient-openlayers.min.js +8 -0
- package/index.js +9 -0
- package/mapping/BaiduMap.js +121 -0
- package/mapping/ImageSuperMapRest.js +252 -0
- package/mapping/ImageTileSuperMapRest.js +99 -0
- package/mapping/InitMap.js +150 -0
- package/mapping/SuperMapCloud.js +56 -0
- package/mapping/Tianditu.js +152 -0
- package/mapping/TileSuperMapRest.js +374 -0
- package/mapping/WebMap.js +5485 -0
- package/mapping/index.js +11 -0
- package/mapping/webmap/Util.js +176 -0
- package/mapping/webmap/config/MunicipalCenter.json +1 -0
- package/mapping/webmap/config/ProvinceCenter.json +1 -0
- package/mapping/webmap/config/SampleDataInfo.json +55 -0
- package/namespace.js +150 -0
- package/overlay/DataFlow.js +114 -0
- package/overlay/FGB.js +100 -0
- package/overlay/Graph.js +439 -0
- package/overlay/GraphMap.js +140 -0
- package/overlay/Graphic.js +588 -0
- package/overlay/HeatMap.js +450 -0
- package/overlay/Label.js +966 -0
- package/overlay/Mapv.js +149 -0
- package/overlay/Range.js +129 -0
- package/overlay/RankSymbol.js +94 -0
- package/overlay/Turf.js +299 -0
- package/overlay/Unique.js +124 -0
- package/overlay/VectorTileSuperMapRest.js +501 -0
- package/overlay/graphic/CanvasRenderer.js +177 -0
- package/overlay/graphic/CloverShape.js +133 -0
- package/overlay/graphic/Graphic.js +174 -0
- package/overlay/graphic/HitCloverShape.js +64 -0
- package/overlay/graphic/WebGLRenderer.js +356 -0
- package/overlay/graphic/index.js +9 -0
- package/overlay/index.js +21 -0
- package/overlay/mapv/MapvCanvasLayer.js +104 -0
- package/overlay/mapv/MapvLayer.js +413 -0
- package/overlay/mapv/index.js +5 -0
- package/overlay/theme/GeoFeature.js +275 -0
- package/overlay/theme/Theme.js +587 -0
- package/overlay/theme/ThemeFeature.js +46 -0
- package/overlay/theme/index.js +6 -0
- package/overlay/vectortile/DeafultCanvasStyle.js +125 -0
- package/overlay/vectortile/MapboxStyles.js +377 -0
- package/overlay/vectortile/StyleMap.js +252 -0
- package/overlay/vectortile/VectorTileStyles.js +554 -0
- package/overlay/vectortile/index.js +7 -0
- package/overlay/vectortile/olExtends.js +382 -0
- package/package.json +30 -0
- package/services/AddressMatchService.js +60 -0
- package/services/ChartService.js +97 -0
- package/services/DataFlowService.js +119 -0
- package/services/DatasetService.js +104 -0
- package/services/DatasourceService.js +76 -0
- package/services/FeatureService.js +260 -0
- package/services/FieldService.js +53 -0
- package/services/GeoprocessingService.js +157 -0
- package/services/GridCellInfosService.js +53 -0
- package/services/ImageCollectionService.js +93 -0
- package/services/ImageService.js +70 -0
- package/services/KnowledgeGraphService.js +96 -0
- package/services/LayerInfoService.js +85 -0
- package/services/MapService.js +85 -0
- package/services/MeasureService.js +77 -0
- package/services/NetworkAnalyst3DService.js +93 -0
- package/services/NetworkAnalystService.js +268 -0
- package/services/ProcessingService.js +507 -0
- package/services/QueryService.js +116 -0
- package/services/ServiceBase.js +26 -0
- package/services/SpatialAnalystService.js +466 -0
- package/services/ThemeService.js +50 -0
- package/services/TrafficTransferAnalystService.js +93 -0
- package/services/WebPrintingJobService.js +112 -0
- package/services/index.js +27 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
|
|
2
|
+
* This program are made available under the terms of the Apache License, Version 2.0
|
|
3
|
+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
|
|
4
|
+
|
|
5
|
+
import XYZ from 'ol/source/XYZ';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @class SuperMapCloud
|
|
9
|
+
* @browsernamespace ol.source
|
|
10
|
+
* @category ThirdPartyMap
|
|
11
|
+
* @classdesc 超图云地图图层源。
|
|
12
|
+
* @modulecategory Mapping
|
|
13
|
+
* @param {Object} opt_options - 参数。
|
|
14
|
+
* @param {string} [opt_options.url='http://t2.dituhui.com/FileService/image?map={mapName}&type={type}&x={x}&y={y}&z={z}'] - 服务地址。
|
|
15
|
+
* @param {string} [opt_options.tileProxy] - 代理地址。
|
|
16
|
+
* @extends {ol.source.XYZ}
|
|
17
|
+
* @usage
|
|
18
|
+
*/
|
|
19
|
+
export class SuperMapCloud extends XYZ {
|
|
20
|
+
|
|
21
|
+
constructor(opt_options) {
|
|
22
|
+
var options = opt_options || {};
|
|
23
|
+
|
|
24
|
+
var attributions = options.attributions || "Map Data ©2014 SuperMap - GS(2014)6070号-data©Navinfo with <span>© SuperMap iClient</span>"
|
|
25
|
+
var mapName = options.mapName || 'quanguo';
|
|
26
|
+
var mapType = options.mapType || 'web';
|
|
27
|
+
var url = options.url || 'http://t2.dituhui.com/FileService/image?map={mapName}&type={type}&x={x}&y={y}&z={z}';
|
|
28
|
+
url = url.replace('{mapName}', mapName).replace('{type}', mapType);
|
|
29
|
+
|
|
30
|
+
var superOptions = {
|
|
31
|
+
attributions: attributions,
|
|
32
|
+
cacheSize: options.cacheSize,
|
|
33
|
+
crossOrigin: options.crossOrigin,
|
|
34
|
+
opaque: options.opaque === undefined ? true : options.opaque,
|
|
35
|
+
maxZoom: options.maxZoom || 18,
|
|
36
|
+
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
|
37
|
+
url: url,
|
|
38
|
+
wrapX: options.wrapX
|
|
39
|
+
};
|
|
40
|
+
//需要代理时走自定义 tileLoadFunction,否则走默认的tileLoadFunction
|
|
41
|
+
if (options.tileProxy) {
|
|
42
|
+
superOptions.tileLoadFunction = tileLoadFunction;
|
|
43
|
+
}
|
|
44
|
+
super(superOptions);
|
|
45
|
+
|
|
46
|
+
if (options.tileProxy) {
|
|
47
|
+
this.tileProxy = options.tileProxy;
|
|
48
|
+
}
|
|
49
|
+
//需要代理时,走以下代码
|
|
50
|
+
var me = this;
|
|
51
|
+
function tileLoadFunction(imageTile, src) {
|
|
52
|
+
//支持代理
|
|
53
|
+
imageTile.getImage().src = me.tileProxy + encodeURIComponent(src);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
|
|
2
|
+
* This program are made available under the terms of the Apache License, Version 2.0
|
|
3
|
+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
|
|
4
|
+
|
|
5
|
+
import WMTS from 'ol/source/WMTS';
|
|
6
|
+
import WMTSTileGrid from 'ol/tilegrid/WMTS';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @class Tianditu
|
|
10
|
+
* @browsernamespace ol.source
|
|
11
|
+
* @category ThirdPartyMap
|
|
12
|
+
* @classdesc 天地图图层源。
|
|
13
|
+
* @modulecategory Mapping
|
|
14
|
+
* @param {Object} opt_options - 参数。
|
|
15
|
+
* @param {string} [opt_options.url='http://t{0-7}.tianditu.gov.cn/{layer}_{proj}/wmts?'] - 服务地址。
|
|
16
|
+
* @param {string} opt_options.key - 天地图服务密钥。详见{@link http://lbs.tianditu.gov.cn/server/MapService.html}
|
|
17
|
+
* @param {string} [opt_options.layerType='vec'] - 图层类型。(vec:矢量图层,img:影像图层,ter:地形图层)
|
|
18
|
+
* @param {string} [opt_options.attributions] - 版权描述信息。
|
|
19
|
+
* @param {number} [opt_options.cacheSize = 2048] - 缓冲大小。
|
|
20
|
+
* @param {function} [opt_options.tileLoadFunction] - 切片加载完成后执行函数。
|
|
21
|
+
* @param {string} [opt_options.style] - 图层风格。
|
|
22
|
+
* @param {string} [opt_options.format='tiles'] - 格式。
|
|
23
|
+
* @param {boolean} [opt_options.isLabel] - 是否是标注图层。
|
|
24
|
+
* @param {boolean} [opt_options.opaque=true] - 是否透明。
|
|
25
|
+
* @param {string} [opt_options.tileProxy] - 代理地址。
|
|
26
|
+
* @extends {ol.source.WMTS}
|
|
27
|
+
* @usage
|
|
28
|
+
*/
|
|
29
|
+
export class Tianditu extends WMTS {
|
|
30
|
+
constructor(opt_options) {
|
|
31
|
+
var layerLabelMap = {
|
|
32
|
+
"vec": "cva",
|
|
33
|
+
"ter": "cta",
|
|
34
|
+
"img": "cia"
|
|
35
|
+
}
|
|
36
|
+
var layerZoomMap = {
|
|
37
|
+
"vec": 18,
|
|
38
|
+
"ter": 14,
|
|
39
|
+
"img": 18
|
|
40
|
+
}
|
|
41
|
+
var options = opt_options || {};
|
|
42
|
+
var attributions = options.attributions || "Map Data <a href='http://www.tianditu.gov.cn' target='_blank'><img style='background-color:transparent;bottom:2px;opacity:1;' " +
|
|
43
|
+
"src='http://api.tianditu.gov.cn/img/map/logo.png' width='53px' height='22px' opacity='0'></a> with " +
|
|
44
|
+
"<span>© SuperMap iClient</span>"
|
|
45
|
+
options.layerType = options.layerType || "vec";
|
|
46
|
+
options.layerType = options.isLabel ? layerLabelMap[options.layerType] : options.layerType;
|
|
47
|
+
options.matrixSet = (options.projection === 'EPSG:4326' || options.projection === 'EPSG:4490') ? "c" : "w";
|
|
48
|
+
if (!options.url && !options.urls) {
|
|
49
|
+
options.url = "http://t{0-7}.tianditu.gov.cn/{layer}_{proj}/wmts?"
|
|
50
|
+
}
|
|
51
|
+
if (options.key) {
|
|
52
|
+
options.url = `${options.url}tk=${options.key}`;
|
|
53
|
+
}
|
|
54
|
+
options.url = options.url.replace("{layer}", options.layerType).replace("{proj}", options.matrixSet);
|
|
55
|
+
var tileGrid = options.tileGrid || Tianditu.getTileGrid(options.projection || 'EPSG:3857');
|
|
56
|
+
|
|
57
|
+
var crossOrigin = options.crossOrigin !== undefined ? options.crossOrigin : 'anonymous';
|
|
58
|
+
|
|
59
|
+
var superOptions = {
|
|
60
|
+
version: options.version || '1.0.0',
|
|
61
|
+
format: options.format || 'tiles',
|
|
62
|
+
dimensions: options.dimensions || {},
|
|
63
|
+
layer: options.layerType,
|
|
64
|
+
matrixSet: options.matrixSet,
|
|
65
|
+
tileGrid: tileGrid,
|
|
66
|
+
style: options.style || 'default',
|
|
67
|
+
attributions: attributions,
|
|
68
|
+
cacheSize: options.cacheSize,
|
|
69
|
+
crossOrigin: crossOrigin,
|
|
70
|
+
opaque: options.opaque === undefined ? true : options.opaque,
|
|
71
|
+
maxZoom: layerZoomMap[options.layerType],
|
|
72
|
+
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
|
73
|
+
url: options.url,
|
|
74
|
+
urls: options.urls,
|
|
75
|
+
projection: options.projection || 'EPSG:3857',
|
|
76
|
+
wrapX: options.wrapX
|
|
77
|
+
};
|
|
78
|
+
//需要代理时走自定义 tileLoadFunction,否则走默认的tileLoadFunction
|
|
79
|
+
if (options.tileProxy) {
|
|
80
|
+
superOptions.tileLoadFunction = tileLoadFunction;
|
|
81
|
+
}
|
|
82
|
+
super(superOptions);
|
|
83
|
+
|
|
84
|
+
if (options.tileProxy) {
|
|
85
|
+
this.tileProxy = options.tileProxy;
|
|
86
|
+
}
|
|
87
|
+
//需要代理时,走以下代码
|
|
88
|
+
var me = this;
|
|
89
|
+
|
|
90
|
+
function tileLoadFunction(imageTile, src) {
|
|
91
|
+
//支持代理
|
|
92
|
+
imageTile.getImage().src = me.tileProxy + encodeURIComponent(src);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @function Tianditu.getTileGrid
|
|
98
|
+
* @description 获取瓦片网格。
|
|
99
|
+
* @param {string} projection - 投影参考对象。
|
|
100
|
+
* @returns {ol.tilegrid.WMTS} 返回瓦片网格对象。
|
|
101
|
+
*/
|
|
102
|
+
static getTileGrid(projection) {
|
|
103
|
+
if (projection === "EPSG:4326" || projection === "EPSG:4490") {
|
|
104
|
+
return Tianditu.default4326TileGrid();
|
|
105
|
+
}
|
|
106
|
+
return Tianditu.default3857TileGrid();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @function Tianditu.default4326TileGrid
|
|
111
|
+
* @description 获取默认 4326 网格瓦片。
|
|
112
|
+
* @returns {ol.tilegrid.WMTS} 返回默认 4326 网格瓦片对象。
|
|
113
|
+
*/
|
|
114
|
+
static default4326TileGrid() {
|
|
115
|
+
var tdt_WGS84_resolutions = [];
|
|
116
|
+
var matrixIds = [];
|
|
117
|
+
for (var i = 1; i < 19; i++) {
|
|
118
|
+
tdt_WGS84_resolutions.push(0.703125 * 2 / (Math.pow(2, i)));
|
|
119
|
+
matrixIds.push(i);
|
|
120
|
+
}
|
|
121
|
+
var tileGird = new WMTSTileGrid({
|
|
122
|
+
extent: [-180, -90, 180, 90],
|
|
123
|
+
resolutions: tdt_WGS84_resolutions,
|
|
124
|
+
origin: [-180, 90],
|
|
125
|
+
matrixIds: matrixIds,
|
|
126
|
+
minZoom: 1
|
|
127
|
+
});
|
|
128
|
+
return tileGird;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @function Tianditu.default3857TileGrid
|
|
133
|
+
* @description 获取默认 3857 网格瓦片。
|
|
134
|
+
* @returns {ol.tilegrid.WMTS} 返回默认 3857 网格瓦片对象。
|
|
135
|
+
*/
|
|
136
|
+
static default3857TileGrid() {
|
|
137
|
+
var tdt_Mercator_resolutions = [];
|
|
138
|
+
var matrixIds = [];
|
|
139
|
+
for (var i = 1; i < 19; i++) {
|
|
140
|
+
tdt_Mercator_resolutions.push(78271.5169640203125 * 2 / (Math.pow(2, i)));
|
|
141
|
+
matrixIds.push(i);
|
|
142
|
+
}
|
|
143
|
+
var tileGird = new WMTSTileGrid({
|
|
144
|
+
extent: [-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892],
|
|
145
|
+
resolutions: tdt_Mercator_resolutions,
|
|
146
|
+
matrixIds: matrixIds,
|
|
147
|
+
origin: [-20037508.3427892, 20037508.3427892],
|
|
148
|
+
minZoom: 1
|
|
149
|
+
});
|
|
150
|
+
return tileGird;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
|
|
2
|
+
* This program are made available under the terms of the Apache License, Version 2.0
|
|
3
|
+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
|
|
4
|
+
import { SecurityManager } from '@supermapgis/iclient-common/security/SecurityManager';
|
|
5
|
+
import { Unit } from '@supermapgis/iclient-common/REST';
|
|
6
|
+
import { Util as CommonUtil } from '@supermapgis/iclient-common/commontypes/Util';
|
|
7
|
+
import { ServerGeometry } from '@supermapgis/iclient-common/iServer/ServerGeometry';
|
|
8
|
+
import { Util } from '../core/Util';
|
|
9
|
+
import TileImage from 'ol/source/TileImage';
|
|
10
|
+
import Geometry from 'ol/geom/Geometry';
|
|
11
|
+
import GeoJSON from 'ol/format/GeoJSON';
|
|
12
|
+
import * as olSize from 'ol/size';
|
|
13
|
+
import * as olTilegrid from 'ol/tilegrid';
|
|
14
|
+
import TileGrid from 'ol/tilegrid/TileGrid';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @class TileSuperMapRest
|
|
18
|
+
* @browsernamespace ol.source
|
|
19
|
+
* @category iServer Map Tile
|
|
20
|
+
* @modulecategory Mapping
|
|
21
|
+
* @classdesc SuperMap iServer TileImage 图层源。
|
|
22
|
+
* @param {Object} options - 参数。
|
|
23
|
+
* @param {string} options.url - 服务地址,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
|
|
24
|
+
* @param {ol.tilegrid.TileGrid} [options.tileGrid] - 瓦片网格对象。当不指定时,会通过 options.extent 或投影范围生成。
|
|
25
|
+
* @param {boolean} [options.redirect = false] - 是否重定向。
|
|
26
|
+
* @param {boolean} [options.transparent = true] - 瓦片是否透明。
|
|
27
|
+
* @param {boolean} [options.cacheEnabled = true] - 是否使用服务端的缓存。
|
|
28
|
+
* @param {Object} [options.prjCoordSys] - 请求的地图的坐标参考系统。当此参数设置的坐标系统不同于地图的原有坐标系统时,系统会进行动态投影,并返回动态投影后的地图瓦片。例如:{"epsgCode":3857}。
|
|
29
|
+
* @param {string} [options.layersID] - 获取进行切片的地图图层 ID,即指定进行地图切片的图层,可以是临时图层集,也可以是当前地图中图层的组合。
|
|
30
|
+
* @param {boolean} [options.clipRegionEnabled = false] - 是否只地图只显示该区域覆盖的部分。true 表示地图只显示该区域覆盖的部分。
|
|
31
|
+
* @param {ol.geom.Geometry} [options.clipRegion] - 地图显示裁剪的区域。是一个面对象,当 clipRegionEnabled = true 时有效,即地图只显示该区域覆盖的部分。
|
|
32
|
+
* @param {boolean} [options.overlapDisplayed = false] - 地图对象在同一范围内时,是否重叠显示。如果为 true,则同一范围内的对象会直接压盖;如果为 false 则通过 overlapDisplayedOptions 控制对象不压盖显示。
|
|
33
|
+
* @param {OverlapDisplayedOptions} [options.overlapDisplayedOptions] - 避免地图对象压盖显示的过滤选项,当 overlapDisplayed 为 false 时有效,用来增强对地图对象压盖时的处理。
|
|
34
|
+
* @param {string} [options.tileversion] - 切片版本名称,_cache 为 true 时有效。
|
|
35
|
+
* @param {string} [options.tileProxy] - 服务代理地址。
|
|
36
|
+
* @param {string} [options.format = 'png'] - 瓦片表述类型,支持 "png" 、"webp"、"bmp" 、"jpg"、"gif" 等图片类型。
|
|
37
|
+
* @param {(NDVIParameter|HillshadeParameter)} [options.rasterfunction] - 栅格分析参数。
|
|
38
|
+
* @param {ChartSetting} [options.chartSetting] - 海图显示参数设置类,用于管理海图显示环境,包括海图的显示模式、显示类型名称、颜色模式、安全水深线等各种显示风格。
|
|
39
|
+
* @extends {ol.source.TileImage}
|
|
40
|
+
* @usage
|
|
41
|
+
*/
|
|
42
|
+
export class TileSuperMapRest extends TileImage {
|
|
43
|
+
constructor(options) {
|
|
44
|
+
options = options || {};
|
|
45
|
+
options.attributions =
|
|
46
|
+
options.attributions || "Map Data <span>© SuperMap iServer</span> with <span>© SuperMap iClient</span>";
|
|
47
|
+
|
|
48
|
+
options.format = options.format ? options.format : 'png';
|
|
49
|
+
|
|
50
|
+
super({
|
|
51
|
+
attributions: options.attributions,
|
|
52
|
+
cacheSize: options.cacheSize,
|
|
53
|
+
crossOrigin: options.crossOrigin,
|
|
54
|
+
logo: Util.getOlVersion() === '4' ? options.logo : null,
|
|
55
|
+
opaque: options.opaque,
|
|
56
|
+
projection: options.projection,
|
|
57
|
+
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
|
58
|
+
state: options.state,
|
|
59
|
+
tileClass: options.tileClass,
|
|
60
|
+
tileGrid: options.tileGrid,
|
|
61
|
+
tileLoadFunction: options.tileLoadFunction,
|
|
62
|
+
tilePixelRatio: options.tilePixelRatio,
|
|
63
|
+
tileUrlFunction: tileUrlFunction,
|
|
64
|
+
wrapX: options.wrapX !== undefined ? options.wrapX : false,
|
|
65
|
+
cacheEnabled: options.cacheEnabled,
|
|
66
|
+
layersID: options.layersID
|
|
67
|
+
});
|
|
68
|
+
if (options.tileProxy) {
|
|
69
|
+
this.tileProxy = options.tileProxy;
|
|
70
|
+
}
|
|
71
|
+
this.options = options;
|
|
72
|
+
this._url = options.url;
|
|
73
|
+
//当前切片在切片集中的index
|
|
74
|
+
this.tileSetsIndex = -1;
|
|
75
|
+
this.tempIndex = -1;
|
|
76
|
+
this.dpi = this.options.dpi || 96;
|
|
77
|
+
var me = this;
|
|
78
|
+
var layerUrl = CommonUtil.urlPathAppend(options.url, 'tileImage.' + options.format);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @function TileSuperMapRest.prototype.getAllRequestParams
|
|
82
|
+
* @description 获取全部请求参数。
|
|
83
|
+
*/
|
|
84
|
+
function getAllRequestParams() {
|
|
85
|
+
var me = this,
|
|
86
|
+
params = {};
|
|
87
|
+
|
|
88
|
+
params['redirect'] = options.redirect !== undefined ? options.redirect : false;
|
|
89
|
+
//切片是否透明
|
|
90
|
+
params['transparent'] = options.transparent !== undefined ? options.transparent : true;
|
|
91
|
+
params['cacheEnabled'] = !(options.cacheEnabled === false);
|
|
92
|
+
//存储一个cacheEnabled参数
|
|
93
|
+
me.cacheEnabled = params['cacheEnabled'];
|
|
94
|
+
params['_cache'] = params['cacheEnabled'];
|
|
95
|
+
|
|
96
|
+
//设置切片原点
|
|
97
|
+
if (this.origin) {
|
|
98
|
+
params['origin'] = JSON.stringify({
|
|
99
|
+
x: this.origin[0],
|
|
100
|
+
y: this.origin[1]
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (options.prjCoordSys) {
|
|
105
|
+
params['prjCoordSys'] = JSON.stringify(options.prjCoordSys);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (options.layersID) {
|
|
109
|
+
params['layersID'] = options.layersID.toString();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (options.clipRegion instanceof Geometry) {
|
|
113
|
+
options.clipRegionEnabled = true;
|
|
114
|
+
options.clipRegion = Util.toSuperMapGeometry(new GeoJSON().writeGeometryObject(options.clipRegion));
|
|
115
|
+
options.clipRegion = CommonUtil.toJSON(ServerGeometry.fromGeometry(options.clipRegion));
|
|
116
|
+
params['clipRegionEnabled'] = options.clipRegionEnabled;
|
|
117
|
+
params['clipRegion'] = JSON.stringify(options.clipRegion);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!options.overlapDisplayed) {
|
|
121
|
+
params['overlapDisplayed'] = false;
|
|
122
|
+
if (options.overlapDisplayedOptions) {
|
|
123
|
+
params['overlapDisplayedOptions'] = me.overlapDisplayedOptions.toString();
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
params['overlapDisplayed'] = true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (params.cacheEnabled && options.tileversion) {
|
|
130
|
+
params['tileversion'] = options.tileversion.toString();
|
|
131
|
+
}
|
|
132
|
+
if (options.rasterfunction) {
|
|
133
|
+
params['rasterfunction'] = JSON.stringify(options.rasterfunction);
|
|
134
|
+
}
|
|
135
|
+
if (options.chartSetting) {
|
|
136
|
+
params["chartSetting"] = JSON.stringify(options.chartSetting);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return params;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @function TileSuperMapRest.prototype.getFullRequestUrl
|
|
144
|
+
* @description 获取完整的请求地址。
|
|
145
|
+
*/
|
|
146
|
+
function getFullRequestUrl() {
|
|
147
|
+
if (this._paramsChanged) {
|
|
148
|
+
this._layerUrl = createLayerUrl.call(this);
|
|
149
|
+
this._paramsChanged = false;
|
|
150
|
+
}
|
|
151
|
+
return this._layerUrl || createLayerUrl.call(this);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @function TileSuperMapRest.prototype.createLayerUrl
|
|
156
|
+
* @description 获取新建图层地址。
|
|
157
|
+
*/
|
|
158
|
+
function createLayerUrl() {
|
|
159
|
+
this.requestParams = this.requestParams || getAllRequestParams.call(this);
|
|
160
|
+
this._layerUrl = CommonUtil.urlAppend(layerUrl, CommonUtil.getParameterString(this.requestParams));
|
|
161
|
+
//为url添加安全认证信息片段
|
|
162
|
+
this._layerUrl = SecurityManager.appendCredential(this._layerUrl);
|
|
163
|
+
return this._layerUrl;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function tileUrlFunction(tileCoord, pixelRatio, projection) {
|
|
167
|
+
if (!me.tileGrid) {
|
|
168
|
+
if (options.extent) {
|
|
169
|
+
me.tileGrid = TileSuperMapRest.createTileGrid(options.extent);
|
|
170
|
+
if (me.resolutions) {
|
|
171
|
+
me.tileGrid.resolutions = me.resolutions;
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
if (projection.getCode() === 'EPSG:3857') {
|
|
175
|
+
me.tileGrid = TileSuperMapRest.createTileGrid([
|
|
176
|
+
-20037508.3427892,
|
|
177
|
+
-20037508.3427892,
|
|
178
|
+
20037508.3427892,
|
|
179
|
+
20037508.3427892
|
|
180
|
+
]);
|
|
181
|
+
me.extent = [-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892];
|
|
182
|
+
}
|
|
183
|
+
if (projection.getCode() === 'EPSG:4326') {
|
|
184
|
+
me.tileGrid = TileSuperMapRest.createTileGrid([-180, -90, 180, 90]);
|
|
185
|
+
me.extent = [-180, -90, 180, 90];
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
me.origin = me.tileGrid.getOrigin(0);
|
|
190
|
+
var z = tileCoord[0];
|
|
191
|
+
var x = tileCoord[1];
|
|
192
|
+
var y = ['4', '5'].indexOf(Util.getOlVersion()) > -1 ? -tileCoord[2] - 1 : tileCoord[2];
|
|
193
|
+
var resolution = me.tileGrid.getResolution(z);
|
|
194
|
+
var dpi = me.dpi || 96;
|
|
195
|
+
var unit = projection.getUnits() || Unit.DEGREE;
|
|
196
|
+
var scale = Util.resolutionToScale(resolution, dpi, unit);
|
|
197
|
+
var tileSize = olSize.toSize(me.tileGrid.getTileSize(z, me.tmpSize));
|
|
198
|
+
var layerUrl = getFullRequestUrl.call(me);
|
|
199
|
+
var url =
|
|
200
|
+
layerUrl +
|
|
201
|
+
encodeURI(
|
|
202
|
+
'&x=' + x + '&y=' + y + '&width=' + tileSize[0] + '&height=' + tileSize[1] + '&scale=' + scale
|
|
203
|
+
);
|
|
204
|
+
//支持代理
|
|
205
|
+
if (me.tileProxy) {
|
|
206
|
+
url = me.tileProxy + encodeURIComponent(url);
|
|
207
|
+
}
|
|
208
|
+
if (!me.cacheEnabled) {
|
|
209
|
+
url += '&_t=' + new Date().getTime();
|
|
210
|
+
}
|
|
211
|
+
return url;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @function TileSuperMapRest.prototype.setTileSetsInfo
|
|
217
|
+
* @description 设置瓦片集信息。
|
|
218
|
+
* @param {Object} tileSets - 瓦片集合。
|
|
219
|
+
*/
|
|
220
|
+
setTileSetsInfo(tileSets) {
|
|
221
|
+
this.tileSets = tileSets;
|
|
222
|
+
if (Util.isArray(this.tileSets)) {
|
|
223
|
+
this.tileSets = tileSets[0];
|
|
224
|
+
}
|
|
225
|
+
if (!this.tileSets) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
this.dispatchEvent({
|
|
229
|
+
type: 'tilesetsinfoloaded',
|
|
230
|
+
value: {
|
|
231
|
+
tileVersions: this.tileSets.tileVersions
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
this.changeTilesVersion();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @function TileSuperMapRest.prototype.lastTilesVersion
|
|
239
|
+
* @description 请求上一个版本切片,并重新绘制。
|
|
240
|
+
*/
|
|
241
|
+
lastTilesVersion() {
|
|
242
|
+
this.tempIndex = this.tileSetsIndex - 1;
|
|
243
|
+
this.changeTilesVersion();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @function TileSuperMapRest.prototype.nextTilesVersion
|
|
248
|
+
* @description 请求下一个版本切片,并重新绘制。
|
|
249
|
+
*/
|
|
250
|
+
nextTilesVersion() {
|
|
251
|
+
this.tempIndex = this.tileSetsIndex + 1;
|
|
252
|
+
this.changeTilesVersion();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @function TileSuperMapRest.prototype.changeTilesVersion
|
|
257
|
+
* @description 切换到某一版本的切片,并重绘。通过 this.tempIndex 保存需要切换的版本索引。
|
|
258
|
+
*/
|
|
259
|
+
changeTilesVersion() {
|
|
260
|
+
var me = this;
|
|
261
|
+
//切片版本集信息是否存在
|
|
262
|
+
if (me.tileSets == null) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (me.tempIndex === me.tileSetsIndex || this.tempIndex < 0) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
//检测index是否可用
|
|
269
|
+
var tileVersions = me.tileSets.tileVersions;
|
|
270
|
+
if (tileVersions && me.tempIndex < tileVersions.length && me.tempIndex >= 0) {
|
|
271
|
+
var name = tileVersions[me.tempIndex].name;
|
|
272
|
+
var result = me.mergeTileVersionParam(name);
|
|
273
|
+
if (result) {
|
|
274
|
+
me.tileSetsIndex = me.tempIndex;
|
|
275
|
+
me.dispatchEvent({
|
|
276
|
+
type: 'tileversionschanged',
|
|
277
|
+
value: {
|
|
278
|
+
tileVersion: tileVersions[me.tempIndex]
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @function TileSuperMapRest.prototype.updateCurrentTileSetsIndex
|
|
287
|
+
* @description 更新当前切片集索引,目前主要提供给控件使用。
|
|
288
|
+
* @param {number} index - 索引号。
|
|
289
|
+
*/
|
|
290
|
+
updateCurrentTileSetsIndex(index) {
|
|
291
|
+
this.tempIndex = index;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @function TileSuperMapRest.prototype.mergeTileVersionParam
|
|
296
|
+
* @description 更改 URL 请求参数中的切片版本号,并重绘。
|
|
297
|
+
* @param {Object} version - 版本信息。
|
|
298
|
+
* @returns {boolean} 是否成功。
|
|
299
|
+
*/
|
|
300
|
+
mergeTileVersionParam(version) {
|
|
301
|
+
if (version) {
|
|
302
|
+
this.requestParams['tileversion'] = version;
|
|
303
|
+
this._paramsChanged = true;
|
|
304
|
+
this.refresh();
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @function TileSuperMapRest.optionsFromMapJSON
|
|
312
|
+
* @description 从 MapJSON 中获取参数对象。
|
|
313
|
+
* @param {string} url - 服务地址。
|
|
314
|
+
* @param {Object} mapJSONObj - 地图 JSON 对象。
|
|
315
|
+
*/
|
|
316
|
+
static optionsFromMapJSON(url, mapJSONObj) {
|
|
317
|
+
var options = {
|
|
318
|
+
};
|
|
319
|
+
if (mapJSONObj.tileFormat) {
|
|
320
|
+
options.format = mapJSONObj.tileFormat;
|
|
321
|
+
}
|
|
322
|
+
if (mapJSONObj.origin) {
|
|
323
|
+
options.origin = mapJSONObj.origin;
|
|
324
|
+
}
|
|
325
|
+
options.url = url;
|
|
326
|
+
options.crossOrigin = 'anonymous';
|
|
327
|
+
var extent = [mapJSONObj.bounds.left, mapJSONObj.bounds.bottom, mapJSONObj.bounds.right, mapJSONObj.bounds.top];
|
|
328
|
+
const { visibleScales, bounds, dpi, coordUnit } = mapJSONObj;
|
|
329
|
+
var resolutions = Util.scalesToResolutions(visibleScales, bounds, dpi, coordUnit);
|
|
330
|
+
options.tileGrid = new TileGrid({
|
|
331
|
+
extent: extent,
|
|
332
|
+
resolutions: resolutions,
|
|
333
|
+
tileSize: mapJSONObj.tileSize || 256
|
|
334
|
+
});
|
|
335
|
+
return options;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* @function TileSuperMapRest.createTileGrid
|
|
340
|
+
* @description 创建切片网格。
|
|
341
|
+
* @param {number} extent - 长度。
|
|
342
|
+
* @param {number} maxZoom - 最大的放大级别。
|
|
343
|
+
* @param {number} minZoom - 最小的放大级别。
|
|
344
|
+
* @param {number} tileSize - 瓦片的尺寸。
|
|
345
|
+
* @param {number} origin - 原点。
|
|
346
|
+
* */
|
|
347
|
+
static createTileGrid(extent, maxZoom, minZoom, tileSize, origin) {
|
|
348
|
+
var tilegrid = olTilegrid.createXYZ({
|
|
349
|
+
extent: extent,
|
|
350
|
+
maxZoom: maxZoom,
|
|
351
|
+
minZoom: minZoom,
|
|
352
|
+
tileSize: tileSize
|
|
353
|
+
});
|
|
354
|
+
return new TileGrid({
|
|
355
|
+
extent: extent,
|
|
356
|
+
minZoom: minZoom,
|
|
357
|
+
origin: origin,
|
|
358
|
+
resolutions: tilegrid.getResolutions(),
|
|
359
|
+
tileSize: tilegrid.getTileSize()
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* @function TileSuperMapRest.updateParams
|
|
365
|
+
* @description 更新参数。
|
|
366
|
+
* @param {Object} params - 参数对象。
|
|
367
|
+
* @version 11.2.0
|
|
368
|
+
*/
|
|
369
|
+
updateParams(params) {
|
|
370
|
+
Object.assign(this.requestParams, params);
|
|
371
|
+
this._paramsChanged = true;
|
|
372
|
+
this.refresh();
|
|
373
|
+
}
|
|
374
|
+
}
|