@supermapgis/iclient-ol 11.1.2
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 +99 -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 +478 -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 +121806 -0
- package/dist/iclient-openlayers-es6.min.js +8 -0
- package/dist/iclient-openlayers.css +668 -0
- package/dist/iclient-openlayers.js +132335 -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 +125 -0
- package/mapping/SuperMapCloud.js +56 -0
- package/mapping/Tianditu.js +152 -0
- package/mapping/TileSuperMapRest.js +358 -0
- package/mapping/WebMap.js +5185 -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 +97 -0
- package/overlay/Graph.js +436 -0
- package/overlay/GraphMap.js +91 -0
- package/overlay/Graphic.js +587 -0
- package/overlay/HeatMap.js +444 -0
- package/overlay/Label.js +964 -0
- package/overlay/Mapv.js +146 -0
- package/overlay/Range.js +127 -0
- package/overlay/RankSymbol.js +94 -0
- package/overlay/Turf.js +298 -0
- package/overlay/Unique.js +123 -0
- package/overlay/VectorTileSuperMapRest.js +466 -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 +63 -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 +410 -0
- package/overlay/mapv/index.js +5 -0
- package/overlay/theme/GeoFeature.js +275 -0
- package/overlay/theme/Theme.js +585 -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 +375 -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 +29 -0
- package/services/AddressMatchService.js +60 -0
- package/services/ChartService.js +74 -0
- package/services/DataFlowService.js +118 -0
- package/services/DatasetService.js +104 -0
- package/services/DatasourceService.js +76 -0
- package/services/FeatureService.js +196 -0
- package/services/FieldService.js +53 -0
- package/services/GeoprocessingService.js +156 -0
- package/services/GridCellInfosService.js +53 -0
- package/services/ImageCollectionService.js +92 -0
- package/services/ImageService.js +69 -0
- package/services/KnowledgeGraphService.js +82 -0
- package/services/LayerInfoService.js +85 -0
- package/services/MapService.js +85 -0
- package/services/MeasureService.js +77 -0
- package/services/NetworkAnalyst3DService.js +88 -0
- package/services/NetworkAnalystService.js +252 -0
- package/services/ProcessingService.js +478 -0
- package/services/QueryService.js +116 -0
- package/services/ServiceBase.js +26 -0
- package/services/SpatialAnalystService.js +432 -0
- package/services/ThemeService.js +50 -0
- package/services/TrafficTransferAnalystService.js +88 -0
- package/services/WebPrintingJobService.js +112 -0
- package/services/index.js +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @supermapgis/iclient-ol
|
|
2
|
+
|
|
3
|
+
@supermapgis/iclient-ol 是一套基于 OpenLayers 的云 GIS 网络客户端开发平台, 支持访问 SuperMap iServer / iEdge / iPortal / iManager / Online 的地图、服务和资源,为用户提供了完整专业的 GIS 能力, 同时提供了优秀的可视化功能。
|
|
4
|
+
|
|
5
|
+
## 简介
|
|
6
|
+
* 官网:[https://iclient.supermap.io](https://iclient.supermap.io)
|
|
7
|
+
* 源码:[https://github.com/SuperMap/iClient-JavaScript/tree/master/src/openlayers](https://github.com/SuperMap/iClient-JavaScript/tree/master/src/openlayers)
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install @supermapgis/iclient-ol
|
|
13
|
+
```
|
|
14
|
+
如果您使用的是 OpenLayers 4,请参考此[文档](https://www.npmjs.com/package/@supermapgis/iclient-openlayers/v/10.0.0)安装 SuperMap iClient for OpenLayers。
|
|
15
|
+
|
|
16
|
+
## 开发
|
|
17
|
+
|
|
18
|
+
在 HTML 文件中引入 CSS 文件
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<link href='https://iclient.supermap.io/web/libs/openlayers/6.1.1/ol.css' rel='stylesheet' />
|
|
22
|
+
|
|
23
|
+
<link href='https://iclient.supermap.io/dist/ol/iclient-ol.min.css' rel='stylesheet' />
|
|
24
|
+
```
|
|
25
|
+
在 JS 文件中加入如下代码
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import Map from 'ol/Map';
|
|
29
|
+
import View from 'ol/View';
|
|
30
|
+
import TileLayer from 'ol/layer/Tile';
|
|
31
|
+
import * as control from 'ol/control';
|
|
32
|
+
import { Logo, TileSuperMapRest } from '@supermapgis/iclient-ol';
|
|
33
|
+
|
|
34
|
+
var url = "https://iserver.supermap.io/iserver/services/map-world/rest/maps/World";
|
|
35
|
+
var map = new Map({
|
|
36
|
+
target: 'map',
|
|
37
|
+
controls: control.defaults({attributionOptions: {collapsed: false}})
|
|
38
|
+
.extend([new Logo()]),
|
|
39
|
+
view: new View({
|
|
40
|
+
center: [0, 0],
|
|
41
|
+
zoom: 2,
|
|
42
|
+
projection: 'EPSG:4326'
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
var layer = new TileLayer({
|
|
46
|
+
source: new TileSuperMapRest({
|
|
47
|
+
url: url,
|
|
48
|
+
wrapX: true
|
|
49
|
+
}),
|
|
50
|
+
projection: 'EPSG:4326'
|
|
51
|
+
});
|
|
52
|
+
map.addLayer(layer);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 示例
|
|
56
|
+
[https://github.com/SuperMap/iClient-JavaScript/tree/master/examples/openlayers](https://github.com/SuperMap/iClient-JavaScript/tree/master/examples/openlayers)
|
|
@@ -0,0 +1,438 @@
|
|
|
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 { MapService } from '../services/MapService';
|
|
5
|
+
import Control from 'ol/control/Control';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @class ChangeTileVersion
|
|
9
|
+
* @aliasclass control.ChangeTileVersion
|
|
10
|
+
* @category Control
|
|
11
|
+
* @classdesc 版本切换控件(目前仅支持 IE10 及以上)暂时不支持自定义位置。
|
|
12
|
+
* @modulecategory Control
|
|
13
|
+
* @extends {ol.control.Control}
|
|
14
|
+
* @param {Object} options -参数。
|
|
15
|
+
* @param {string} [options.title='switch tile version'] - 提示信息。
|
|
16
|
+
* @param {string} [options.tooltip='top'] - 提示显示位置 top | right | bottom | left。
|
|
17
|
+
* @param {boolean} [options.collapsed=true] - 是否折叠。
|
|
18
|
+
* @param {string} [options.lastText='-'] - 上一个版本的按钮布局。
|
|
19
|
+
* @param {string} [options.nextText='+'] - 下一个版本的按钮布局。
|
|
20
|
+
* @param {string} [options.ico='V'] - 控件显示的logo。
|
|
21
|
+
* @param {string} [options.orientation='horizontal'] - 方向 horizontal|vertical。
|
|
22
|
+
* @param {boolean} [options.switch=true] - 是否显示上/下一个版本切换控件。
|
|
23
|
+
* @example
|
|
24
|
+
* var control = new ChangeTileVersion({
|
|
25
|
+
* layer: baseLayer,
|
|
26
|
+
* orientation: "horizontal"
|
|
27
|
+
* });
|
|
28
|
+
* map.addControl(control)
|
|
29
|
+
* @usage
|
|
30
|
+
*/
|
|
31
|
+
export class ChangeTileVersion extends Control {
|
|
32
|
+
constructor(options) {
|
|
33
|
+
options = options || {};
|
|
34
|
+
//鼠标滑过时提示
|
|
35
|
+
if (!options.title) {
|
|
36
|
+
options.title = 'switch tile version';
|
|
37
|
+
}
|
|
38
|
+
//tooltip提示显示位置 top | right | bottom | left
|
|
39
|
+
if (!options.tooltip) {
|
|
40
|
+
options.tooltip = 'top';
|
|
41
|
+
}
|
|
42
|
+
//是否折叠
|
|
43
|
+
if (!options.collapsed) {
|
|
44
|
+
options.collapsed = true;
|
|
45
|
+
}
|
|
46
|
+
//上一个版本的按钮布局
|
|
47
|
+
if (!options.lastText) {
|
|
48
|
+
options.lastText = '-';
|
|
49
|
+
}
|
|
50
|
+
//下一个版本的按钮布局
|
|
51
|
+
if (!options.nextText) {
|
|
52
|
+
options.nextText = '+';
|
|
53
|
+
}
|
|
54
|
+
//控件显示的logo
|
|
55
|
+
if (!options.ico) {
|
|
56
|
+
options.ico = 'V';
|
|
57
|
+
}
|
|
58
|
+
//方向horizontal|vertical
|
|
59
|
+
if (options.orientation !== 'vertical') {
|
|
60
|
+
options.orientation = 'horizontal';
|
|
61
|
+
}
|
|
62
|
+
//是否显示上/下一个版本切换控件
|
|
63
|
+
if (!options.switch) {
|
|
64
|
+
options.switch = true;
|
|
65
|
+
}
|
|
66
|
+
super(options);
|
|
67
|
+
this.options = options;
|
|
68
|
+
this.element = options.element = initLayout.call(this);
|
|
69
|
+
|
|
70
|
+
if (options.layer) {
|
|
71
|
+
this.setLayer(options.layer);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @function ChangeTileVersion.prototype.initLayout
|
|
76
|
+
* @description 初始化。
|
|
77
|
+
*/
|
|
78
|
+
function initLayout() {
|
|
79
|
+
var className = 'ol-control-ctv';
|
|
80
|
+
this._container = createElement(
|
|
81
|
+
'div',
|
|
82
|
+
className + ' ' + className + '-' + options.orientation + ' ol-unselectable ol-control'
|
|
83
|
+
);
|
|
84
|
+
//正常情况下显示btn
|
|
85
|
+
this._sliderBtn = createElement('button', className + '-toggle', this._container);
|
|
86
|
+
this._sliderBtn.setAttribute('title', options.title);
|
|
87
|
+
this._sliderBtn.innerHTML = options.ico;
|
|
88
|
+
|
|
89
|
+
//滑块拖动时值显示区域
|
|
90
|
+
this._sliderValue = createElement('p', className + '-value', this._container);
|
|
91
|
+
this._sliderValue.innerHTML = options.ico;
|
|
92
|
+
this._sliderValue.setAttribute('title', options.title);
|
|
93
|
+
|
|
94
|
+
var sliderClassName = 'ol-ctv-slider';
|
|
95
|
+
this._sliderContent = createElement('div', sliderClassName + '-main' + ' tooltip', this._container);
|
|
96
|
+
|
|
97
|
+
//tooltip提示框
|
|
98
|
+
if (options.orientation === 'vertical' && options.tooltip === 'top') {
|
|
99
|
+
options.tooltip = 'right';
|
|
100
|
+
}
|
|
101
|
+
this.tooltip = createElement(
|
|
102
|
+
'span',
|
|
103
|
+
'tooltip-text' + ' ' + 'tooltip-' + options.tooltip,
|
|
104
|
+
this._sliderContent
|
|
105
|
+
);
|
|
106
|
+
this.tooltip.innerHTML = options.ico;
|
|
107
|
+
|
|
108
|
+
//加控件
|
|
109
|
+
if (options.switch) {
|
|
110
|
+
this._next = createElement(
|
|
111
|
+
'a',
|
|
112
|
+
sliderClassName + '-incdec' + ' ' + sliderClassName + '-next',
|
|
113
|
+
this._sliderContent
|
|
114
|
+
);
|
|
115
|
+
this._next.innerHTML = options.nextText;
|
|
116
|
+
addDomEvent(this._next, 'click', this.nextTilesVersion, this);
|
|
117
|
+
this._container.classList.add(className + '-incdec');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//滑块
|
|
121
|
+
this._sliderContainer = createElement('div', sliderClassName + '-container', this._sliderContent);
|
|
122
|
+
this.slider = createElement('input', sliderClassName, this._sliderContainer);
|
|
123
|
+
|
|
124
|
+
this.min = this.min == null || isNaN(this.min) ? 0 : parseInt(this.min);
|
|
125
|
+
this.slider.setAttribute('title', options.title);
|
|
126
|
+
this.slider.setAttribute('id', 'slider');
|
|
127
|
+
this.slider.setAttribute('type', 'range');
|
|
128
|
+
this.slider.setAttribute('min', this.min);
|
|
129
|
+
this.slider.setAttribute('max', 0);
|
|
130
|
+
this.slider.setAttribute('step', 1);
|
|
131
|
+
this.slider.setAttribute('value', 0);
|
|
132
|
+
|
|
133
|
+
// //判断浏览器是否支持Range滑动条
|
|
134
|
+
// if (this.slider.type == "text") {
|
|
135
|
+
// console.error("抱歉,您的浏览器不支持HTML5 range滑动条,请使用高版本浏览器");
|
|
136
|
+
// }
|
|
137
|
+
this.firstLoad = true;
|
|
138
|
+
if ('oninput' in this.slider || 'onchange' in this.slider) {
|
|
139
|
+
addDomEvent(this.slider, 'change', tilesVersion, this);
|
|
140
|
+
} else {
|
|
141
|
+
this.slider.onpropertychange = tilesVersion;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//减控件
|
|
145
|
+
if (options.switch) {
|
|
146
|
+
this._last = createElement(
|
|
147
|
+
'a',
|
|
148
|
+
sliderClassName + '-incdec' + ' ' + sliderClassName + '-last',
|
|
149
|
+
this._sliderContent
|
|
150
|
+
);
|
|
151
|
+
this._last.innerHTML = options.lastText;
|
|
152
|
+
addDomEvent(this._last, 'click', this.lastTilesVersion, this);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// if (window.matchMedia("screen and (-webkit-min-device-pixel-ratio:0)").matches && options.orientation == 'vertical') {
|
|
156
|
+
if (options.orientation == 'vertical') {
|
|
157
|
+
this.slider.style.width = 170 + 'px';
|
|
158
|
+
this._sliderContainer.style.height = 170 + 'px';
|
|
159
|
+
} else {
|
|
160
|
+
this._sliderContainer.style.width = 150 + 'px';
|
|
161
|
+
}
|
|
162
|
+
addDomEvent(
|
|
163
|
+
this._container,
|
|
164
|
+
'click',
|
|
165
|
+
function(e) {
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
e.stopPropagation();
|
|
168
|
+
},
|
|
169
|
+
this
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
if (options.collapsed) {
|
|
173
|
+
addDomEvent(this._container, 'mouseenter', expand, this);
|
|
174
|
+
addDomEvent(this._container, 'mouseleave', collapse, this);
|
|
175
|
+
addDomEvent(this._sliderBtn, 'click', function(e) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
e.stopPropagation();
|
|
178
|
+
});
|
|
179
|
+
addDomEvent(this._sliderBtn, 'click', expand, this);
|
|
180
|
+
addDomEvent(this._sliderBtn, 'focus', expand, this);
|
|
181
|
+
} else {
|
|
182
|
+
expand();
|
|
183
|
+
}
|
|
184
|
+
return this._container;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @function ChangeTileVersion.prototype.createElement
|
|
189
|
+
* @description 新建元素。
|
|
190
|
+
* @param {string} tagName - 标签名。
|
|
191
|
+
* @param {string} className - 类名。
|
|
192
|
+
* @param {Object} container - 容器。
|
|
193
|
+
* @returns {object|HTMLElement} 元素。
|
|
194
|
+
*/
|
|
195
|
+
function createElement(tagName, className, container) {
|
|
196
|
+
var el = document.createElement(tagName);
|
|
197
|
+
el.className = className || '';
|
|
198
|
+
|
|
199
|
+
if (container) {
|
|
200
|
+
container.appendChild(el);
|
|
201
|
+
}
|
|
202
|
+
return el;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @function ChangeTileVersion.prototype.addDomEvent
|
|
207
|
+
* @description 为元素添加事件。
|
|
208
|
+
* @param {Object} obj - 事件对象集。
|
|
209
|
+
* @param {string} type - 事件类型。
|
|
210
|
+
* @param {Object} fn -容器。
|
|
211
|
+
* @param {Object} context -当前环境。
|
|
212
|
+
* @returns {function} 添加的事件。
|
|
213
|
+
*/
|
|
214
|
+
function addDomEvent(obj, type, fn, context) {
|
|
215
|
+
var handler = function(e) {
|
|
216
|
+
if (fn) {
|
|
217
|
+
return fn.call(context || obj, e || window.event);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
var originalHandler = handler;
|
|
221
|
+
if ('addEventListener' in obj) {
|
|
222
|
+
if (type === 'mousewheel') {
|
|
223
|
+
obj.addEventListener('onwheel' in obj ? 'wheel' : 'mousewheel', handler, false);
|
|
224
|
+
} else if (type === 'mouseenter' || type === 'mouseleave') {
|
|
225
|
+
handler = function(e) {
|
|
226
|
+
e = e || window.event;
|
|
227
|
+
if (isExternalTarget(obj, e)) {
|
|
228
|
+
originalHandler(e);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
obj.addEventListener(type === 'mouseenter' ? 'mouseover' : 'mouseout', handler, false);
|
|
232
|
+
} else {
|
|
233
|
+
obj.addEventListener(type, handler, false);
|
|
234
|
+
}
|
|
235
|
+
} else if ('attachEvent' in obj) {
|
|
236
|
+
obj.attachEvent('on' + type, handler);
|
|
237
|
+
}
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function isExternalTarget(el, e) {
|
|
242
|
+
var related = e.relatedTarget;
|
|
243
|
+
if (!related) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
while (related && related !== el) {
|
|
248
|
+
related = related.parentNode;
|
|
249
|
+
}
|
|
250
|
+
} catch (err) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
return related !== el;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function expand() {
|
|
257
|
+
this._container.classList.add('ol-control-ctv-expanded');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function collapse() {
|
|
261
|
+
this._container.classList.remove('ol-control-ctv-expanded');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function tilesVersion() {
|
|
265
|
+
var version = this.getVersion();
|
|
266
|
+
this.tilesVersion(version);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* @function ChangeTileVersion.prototype.setContent
|
|
272
|
+
* @description 设置版本相关信息。
|
|
273
|
+
* @param {Object} version - 版本信息。
|
|
274
|
+
*/
|
|
275
|
+
setContent(version) {
|
|
276
|
+
var content = version || {};
|
|
277
|
+
this.setVersionName(content.desc).setToolTip(content.desc);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* @function ChangeTileVersion.prototype.setVersionName
|
|
282
|
+
* @description 设置版本号
|
|
283
|
+
* @param {string} content -版本内容。
|
|
284
|
+
*/
|
|
285
|
+
setVersionName(content) {
|
|
286
|
+
var value = content;
|
|
287
|
+
if (!content) {
|
|
288
|
+
value = this.getValue();
|
|
289
|
+
}
|
|
290
|
+
this._sliderValue.innerHTML = value;
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @function ChangeTileVersion.prototype.setToolTip
|
|
296
|
+
* @description 设置提示信息。
|
|
297
|
+
* @param {string} tooltip - 提示信息。
|
|
298
|
+
* @returns {ChangeTileVersion} ChangeTileVersion的实例对象。
|
|
299
|
+
*/
|
|
300
|
+
setToolTip(tooltip) {
|
|
301
|
+
this.tooltip.innerHTML = tooltip;
|
|
302
|
+
return this;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @function ChangeTileVersion.prototype.updateLength
|
|
307
|
+
* @description 更新进度条长度。
|
|
308
|
+
* @param {number} length - 进度条长度。
|
|
309
|
+
*/
|
|
310
|
+
updateLength(length) {
|
|
311
|
+
if (length > 0) {
|
|
312
|
+
this.length = length;
|
|
313
|
+
this.max = this.length - 1;
|
|
314
|
+
this.slider.setAttribute('max', this.max);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @function ChangeTileVersion.prototype.setLayer
|
|
320
|
+
* @description 绑定图层。
|
|
321
|
+
* @param {Object} layer - 图层。
|
|
322
|
+
*/
|
|
323
|
+
setLayer(layer) {
|
|
324
|
+
if (layer) {
|
|
325
|
+
this.options.layer = layer;
|
|
326
|
+
}
|
|
327
|
+
var me = this;
|
|
328
|
+
var tileLayer = me.options.layer;
|
|
329
|
+
tileLayer.on('tilesetsinfoloaded', function(evt) {
|
|
330
|
+
var tileVersions = evt.value && evt.value.tileVersions;
|
|
331
|
+
me.update(tileVersions);
|
|
332
|
+
});
|
|
333
|
+
tileLayer.on('tileversionschanged', function(evt) {
|
|
334
|
+
var tileVersions = evt.value && evt.value.tileVersion;
|
|
335
|
+
me.setContent(tileVersions);
|
|
336
|
+
});
|
|
337
|
+
me.getTileSetsInfo();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* @function ChangeTileVersion.prototype.update
|
|
342
|
+
* @description 更新缓存切片集及进度条长度。
|
|
343
|
+
* @param {Object} tileVersions - 待更新的切片版本。
|
|
344
|
+
*/
|
|
345
|
+
update(tileVersions) {
|
|
346
|
+
this.tileVersions = tileVersions ||[];
|
|
347
|
+
this.updateLength(this.tileVersions.length);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* @function ChangeTileVersion.prototype.getTileSetsInfo
|
|
352
|
+
* @description 请求获取切片集信息。
|
|
353
|
+
*/
|
|
354
|
+
getTileSetsInfo() {
|
|
355
|
+
var me = this;
|
|
356
|
+
if (me.options.layer) {
|
|
357
|
+
new MapService(me.options.layer._url).getTilesets(function getTilesInfoSucceed(info) {
|
|
358
|
+
me.options.layer.setTileSetsInfo(info.result);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* @function ChangeTileVersion.prototype.removeLayer
|
|
365
|
+
* @description 移除绑定的地图图层。
|
|
366
|
+
*/
|
|
367
|
+
removeLayer() {
|
|
368
|
+
this.options.layer = null;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* @function ChangeTileVersion.prototype.nextTilesVersion
|
|
373
|
+
* @description 下一个版本,第一次不进行加减,是无版本的状态。
|
|
374
|
+
* @returns {ChangeTileVersion} ChangeTileVersion的实例对象。
|
|
375
|
+
*/
|
|
376
|
+
nextTilesVersion() {
|
|
377
|
+
if (this.firstLoad) {
|
|
378
|
+
this.options.layer.nextTilesVersion();
|
|
379
|
+
this.firstLoad = !!0;
|
|
380
|
+
return this;
|
|
381
|
+
}
|
|
382
|
+
if (parseInt(this.slider.value) > this.max - 1) {
|
|
383
|
+
return this;
|
|
384
|
+
}
|
|
385
|
+
this.slider.value = parseInt(this.slider.value) + 1;
|
|
386
|
+
this.options.layer.nextTilesVersion();
|
|
387
|
+
return this;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* @function ChangeTileVersion.prototype.lastTilesVersion
|
|
392
|
+
* @description 获取上一个版本信息。
|
|
393
|
+
* @returns {ChangeTileVersion} ChangeTileVersion的实例对象。
|
|
394
|
+
*/
|
|
395
|
+
lastTilesVersion() {
|
|
396
|
+
if (parseInt(this.slider.value) < this.min + 1) {
|
|
397
|
+
return this;
|
|
398
|
+
}
|
|
399
|
+
this.slider.value = parseInt(this.slider.value) - 1;
|
|
400
|
+
this.options.layer.lastTilesVersion();
|
|
401
|
+
return this;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* @function ChangeTileVersion.prototype.tilesVersion
|
|
406
|
+
* @description 根据指定版本号请求版本。
|
|
407
|
+
* @param {Object} version - 版本信息。
|
|
408
|
+
*/
|
|
409
|
+
tilesVersion(version) {
|
|
410
|
+
var layer = this.options.layer,
|
|
411
|
+
tileVersions = this.tileVersions;
|
|
412
|
+
var len = tileVersions.length;
|
|
413
|
+
for (var i = 0; i < len; i++) {
|
|
414
|
+
if (tileVersions[i].name == version) {
|
|
415
|
+
layer.updateCurrentTileSetsIndex(i);
|
|
416
|
+
layer.changeTilesVersion();
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* @function ChangeTileVersion.prototype.getValue
|
|
424
|
+
* @description 获取进度条的值。注:(进度条的值并不是版本号)。
|
|
425
|
+
*/
|
|
426
|
+
getValue() {
|
|
427
|
+
return this.slider.value;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* @function ChangeTileVersion.prototype.getVersion
|
|
432
|
+
* @description 获取当前进度条值对应的版本号。
|
|
433
|
+
*/
|
|
434
|
+
getVersion() {
|
|
435
|
+
var version = this.tileVersions[this.getValue()];
|
|
436
|
+
return version && version.name;
|
|
437
|
+
}
|
|
438
|
+
}
|
package/control/Logo.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
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 {LogoBase64} from '@supermapgis/iclient-common/control/img/Logo';
|
|
5
|
+
import Control from 'ol/control/Control';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @class Logo
|
|
9
|
+
* @aliasclass control.Logo
|
|
10
|
+
* @category Control
|
|
11
|
+
* @classdesc Logo控件。默认不显示,需手动添加控件。
|
|
12
|
+
* @modulecategory Control
|
|
13
|
+
* @extends {ol.control.Control}
|
|
14
|
+
* @example
|
|
15
|
+
* var control = new Logo();
|
|
16
|
+
* map.addControl(control);
|
|
17
|
+
* @param {Object} options - 参数。
|
|
18
|
+
* @param {string} [options.imageUrl] - logo 图片地址。
|
|
19
|
+
* @param {number} [options.width] - logo 图片宽。
|
|
20
|
+
* @param {number} [options.height] - logo 图片高。
|
|
21
|
+
* @param {string} [options.link='https://iclient.supermap.io'] - 跳转链接。
|
|
22
|
+
* @param {string} [options.alt='SuperMap iClient'] - logo 图片失效时显示文本。
|
|
23
|
+
* @usage
|
|
24
|
+
*/
|
|
25
|
+
export class Logo extends Control {
|
|
26
|
+
|
|
27
|
+
constructor(options) {
|
|
28
|
+
options = options || {};
|
|
29
|
+
options.imageUrl = options.imageUrl || null;
|
|
30
|
+
options.width = options.width || null;
|
|
31
|
+
options.height = options.height || null;
|
|
32
|
+
options.alt = options.alt || "SuperMap iClient";
|
|
33
|
+
super(options);
|
|
34
|
+
this.options = options;
|
|
35
|
+
this.element = options.element = initLayerout.call(this);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @function Logo.prototype.initLayerout
|
|
39
|
+
* @description 初始化图层信息。
|
|
40
|
+
*/
|
|
41
|
+
function initLayerout() {
|
|
42
|
+
var className = 'ol-control-logo ol-unselectable ol-control';
|
|
43
|
+
var div = document.createElement("div");
|
|
44
|
+
div.className = className;
|
|
45
|
+
|
|
46
|
+
setDivStyle.call(this, div);
|
|
47
|
+
|
|
48
|
+
var imgSrc = LogoBase64;
|
|
49
|
+
if (this.options.imageUrl) {
|
|
50
|
+
imgSrc = this.options.imageUrl;
|
|
51
|
+
}
|
|
52
|
+
var alt = this.options.alt;
|
|
53
|
+
var link = this.options.link;
|
|
54
|
+
|
|
55
|
+
var imageWidth = "94px";
|
|
56
|
+
var imageHeight = "29px";
|
|
57
|
+
var styleSize = "width:" + imageWidth + ";height:" + imageHeight + ";";
|
|
58
|
+
if (this.options.imageUrl) {
|
|
59
|
+
imageWidth = this.options.width;
|
|
60
|
+
imageHeight = this.options.height;
|
|
61
|
+
styleSize = "width:" + imageWidth + ";height:" + imageHeight + ";";
|
|
62
|
+
if (!imageWidth || !imageHeight) {
|
|
63
|
+
styleSize = "";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
div.innerHTML = "<a href='" + link + "' target='_blank' style='border: none;display: block;'>" +
|
|
69
|
+
"<img src=" + imgSrc + " alt='" + alt + "' style='border: none;" + styleSize + "white-space: nowrap;margin-bottom: 2px'></a>";
|
|
70
|
+
return div;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @function Logo.prototype.setDivStyle
|
|
75
|
+
* @description 设置对象 style。
|
|
76
|
+
* @param {HTMLElement} div - 待设置的 div。
|
|
77
|
+
*/
|
|
78
|
+
function setDivStyle(div) {
|
|
79
|
+
var attributionsElem = document.getElementsByClassName('ol-attribution');
|
|
80
|
+
attributionsElem = attributionsElem && attributionsElem[0];
|
|
81
|
+
var attrHeight = attributionsElem && attributionsElem.clientHeight || 29;
|
|
82
|
+
div.style.bottom = (parseInt(attrHeight) + 6) + "px";
|
|
83
|
+
div.style.right = "4px";
|
|
84
|
+
div.style.marginTop = 0;
|
|
85
|
+
div.style.marginLeft = 0;
|
|
86
|
+
div.style.marginBottom = 0;
|
|
87
|
+
div.style.marginRight = 0;
|
|
88
|
+
var logoStyle = document.createElement('style');
|
|
89
|
+
logoStyle.type = 'text/css';
|
|
90
|
+
logoStyle.innerHTML = '.ol-control-logo,.ol-control-logo:hover {' +
|
|
91
|
+
'background-color: rgba(255,255,255,0);' +
|
|
92
|
+
'}';
|
|
93
|
+
document.getElementsByTagName('head')[0].appendChild(logoStyle);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|