my-openlayer 1.0.14 → 2.0.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/MyOl.d.ts +128 -128
- package/MyOl.js +381 -382
- package/README.md +292 -48
- package/core/ConfigManager.d.ts +88 -88
- package/core/ConfigManager.js +112 -112
- package/core/DomPoint.d.ts +21 -0
- package/core/DomPoint.js +36 -0
- package/core/EventManager.d.ts +141 -141
- package/core/EventManager.js +316 -316
- package/core/Line.d.ts +109 -109
- package/core/Line.js +288 -283
- package/core/MapBaseLayers.d.ts +234 -234
- package/core/MapBaseLayers.js +573 -573
- package/core/MapTools.d.ts +68 -68
- package/core/MapTools.js +201 -202
- package/core/MeasureHandler.d.ts +65 -65
- package/core/MeasureHandler.js +312 -312
- package/core/Point.d.ts +94 -94
- package/core/Point.js +348 -343
- package/core/Polygon.d.ts +139 -139
- package/core/Polygon.js +529 -529
- package/core/VueTemplatePoint.d.ts +51 -51
- package/core/VueTemplatePoint.js +529 -529
- package/index.d.ts +18 -18
- package/index.js +17 -17
- package/package.json +4 -5
- package/types.d.ts +302 -302
- package/types.js +11 -11
- package/utils/ErrorHandler.d.ts +102 -102
- package/utils/ErrorHandler.js +191 -191
- package/utils/ValidationUtils.d.ts +163 -163
- package/utils/ValidationUtils.js +312 -312
package/core/Line.js
CHANGED
|
@@ -1,283 +1,288 @@
|
|
|
1
|
-
import VectorSource from "ol/source/Vector";
|
|
2
|
-
import GeoJSON from "ol/format/GeoJSON";
|
|
3
|
-
import VectorLayer from "ol/layer/Vector";
|
|
4
|
-
import { Stroke, Style } from "ol/style";
|
|
5
|
-
import { Feature } from "ol";
|
|
6
|
-
import MapTools from "./MapTools";
|
|
7
|
-
import { ValidationUtils } from "../utils/ValidationUtils";
|
|
8
|
-
import { EventManager } from "./EventManager";
|
|
9
|
-
/**
|
|
10
|
-
* 线要素管理类
|
|
11
|
-
* 用于在地图上添加和管理线要素,包括普通线要素、河流图层等
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const lineManager = new Line(map);
|
|
16
|
-
* const layer = lineManager.addLine(geoJsonData, {
|
|
17
|
-
* type: 'road',
|
|
18
|
-
* strokeColor: '#ff0000',
|
|
19
|
-
* strokeWidth: 3
|
|
20
|
-
* });
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export default class Line {
|
|
24
|
-
/**
|
|
25
|
-
* 构造函数
|
|
26
|
-
* @param map OpenLayers地图实例
|
|
27
|
-
*/
|
|
28
|
-
constructor(map) {
|
|
29
|
-
/** 河流图层列表 */
|
|
30
|
-
this.riverLayerList = [];
|
|
31
|
-
/** 河流图层显示状态 */
|
|
32
|
-
this.riverLayerShow = false;
|
|
33
|
-
/** 默认河流级别宽度映射 */
|
|
34
|
-
this.defaultLevelWidthMap = {
|
|
35
|
-
1: 2,
|
|
36
|
-
2: 1,
|
|
37
|
-
3: 0.5,
|
|
38
|
-
4: 0.5,
|
|
39
|
-
5: 0.5
|
|
40
|
-
};
|
|
41
|
-
ValidationUtils.validateMapInstance(map);
|
|
42
|
-
this.map = map;
|
|
43
|
-
this.eventManager = new EventManager(map);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* 添加线要素
|
|
47
|
-
* @param data GeoJSON格式的线数据
|
|
48
|
-
* @param options 配置项
|
|
49
|
-
* @returns 创建的矢量图层
|
|
50
|
-
*/
|
|
51
|
-
addLine(data, options = {}) {
|
|
52
|
-
ValidationUtils.validateGeoJSONData(data);
|
|
53
|
-
const defaultOptions = {
|
|
54
|
-
type: 'line',
|
|
55
|
-
strokeColor: 'rgba(3, 122, 255, 1)',
|
|
56
|
-
strokeWidth: 2,
|
|
57
|
-
visible: true,
|
|
58
|
-
zIndex: 15,
|
|
59
|
-
layerName: options.layerName || 'lineLayer'
|
|
60
|
-
};
|
|
61
|
-
const mergedOptions = { ...defaultOptions, ...options };
|
|
62
|
-
const features = new GeoJSON().readFeatures(data, options.projectionOptOptions);
|
|
63
|
-
const layer = new VectorLayer({
|
|
64
|
-
properties: {
|
|
65
|
-
name: mergedOptions.layerName,
|
|
66
|
-
layerName: mergedOptions.layerName
|
|
67
|
-
},
|
|
68
|
-
source: new VectorSource({ features }),
|
|
69
|
-
style: (feature) => {
|
|
70
|
-
if (feature instanceof Feature) {
|
|
71
|
-
feature.set('type', mergedOptions.type);
|
|
72
|
-
feature.set('layerName', mergedOptions.type);
|
|
73
|
-
}
|
|
74
|
-
return new Style({
|
|
75
|
-
stroke: new Stroke({
|
|
76
|
-
color: mergedOptions.strokeColor,
|
|
77
|
-
width: mergedOptions.strokeWidth,
|
|
78
|
-
lineDash: mergedOptions.lineDash,
|
|
79
|
-
lineDashOffset: mergedOptions.lineDashOffset
|
|
80
|
-
})
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
zIndex: mergedOptions.zIndex
|
|
84
|
-
});
|
|
85
|
-
layer.setVisible(mergedOptions.visible);
|
|
86
|
-
this.map.addLayer(layer);
|
|
87
|
-
return layer;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* 添加分级河流图层,根据缩放级别显示不同级别的河流
|
|
91
|
-
* @param fyRiverJson 河流 GeoJSON 数据
|
|
92
|
-
* @param options 河流图层配置选项
|
|
93
|
-
* @throws {Error} 当数据格式无效时抛出错误
|
|
94
|
-
*/
|
|
95
|
-
addRiverLayersByZoom(fyRiverJson, options = {}) {
|
|
96
|
-
ValidationUtils.validateGeoJSONData(fyRiverJson);
|
|
97
|
-
const defaultOptions = {
|
|
98
|
-
type: 'river',
|
|
99
|
-
levelCount: 5,
|
|
100
|
-
zoomOffset: 8,
|
|
101
|
-
strokeColor: 'rgb(0,113,255)',
|
|
102
|
-
strokeWidth: 3,
|
|
103
|
-
visible: true,
|
|
104
|
-
zIndex: 15,
|
|
105
|
-
layerName: 'riverLayer',
|
|
106
|
-
removeExisting: options.removeExisting ?? false,
|
|
107
|
-
levelWidthMap: this.defaultLevelWidthMap
|
|
108
|
-
};
|
|
109
|
-
const mergedOptions = { ...defaultOptions, ...options };
|
|
110
|
-
// 清除现有河流图层
|
|
111
|
-
if (mergedOptions.removeExisting) {
|
|
112
|
-
this.clearRiverLayers();
|
|
113
|
-
}
|
|
114
|
-
this.riverLayerShow = mergedOptions.visible;
|
|
115
|
-
this.riverLayerList = [];
|
|
116
|
-
// 创建分级河流图层
|
|
117
|
-
for (let level = 1; level <= mergedOptions.levelCount; level++) {
|
|
118
|
-
const vectorSource = new VectorSource({
|
|
119
|
-
format: new GeoJSON(),
|
|
120
|
-
loader: () => {
|
|
121
|
-
const geojson = new GeoJSON();
|
|
122
|
-
fyRiverJson.features.forEach((feature) => {
|
|
123
|
-
if (feature.properties && feature.properties.level === level) {
|
|
124
|
-
try {
|
|
125
|
-
const olFeature = geojson.readFeature(feature);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
this.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
1
|
+
import VectorSource from "ol/source/Vector";
|
|
2
|
+
import GeoJSON from "ol/format/GeoJSON";
|
|
3
|
+
import VectorLayer from "ol/layer/Vector";
|
|
4
|
+
import { Stroke, Style } from "ol/style";
|
|
5
|
+
import { Feature } from "ol";
|
|
6
|
+
import MapTools from "./MapTools";
|
|
7
|
+
import { ValidationUtils } from "../utils/ValidationUtils";
|
|
8
|
+
import { EventManager } from "./EventManager";
|
|
9
|
+
/**
|
|
10
|
+
* 线要素管理类
|
|
11
|
+
* 用于在地图上添加和管理线要素,包括普通线要素、河流图层等
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const lineManager = new Line(map);
|
|
16
|
+
* const layer = lineManager.addLine(geoJsonData, {
|
|
17
|
+
* type: 'road',
|
|
18
|
+
* strokeColor: '#ff0000',
|
|
19
|
+
* strokeWidth: 3
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export default class Line {
|
|
24
|
+
/**
|
|
25
|
+
* 构造函数
|
|
26
|
+
* @param map OpenLayers地图实例
|
|
27
|
+
*/
|
|
28
|
+
constructor(map) {
|
|
29
|
+
/** 河流图层列表 */
|
|
30
|
+
this.riverLayerList = [];
|
|
31
|
+
/** 河流图层显示状态 */
|
|
32
|
+
this.riverLayerShow = false;
|
|
33
|
+
/** 默认河流级别宽度映射 */
|
|
34
|
+
this.defaultLevelWidthMap = {
|
|
35
|
+
1: 2,
|
|
36
|
+
2: 1,
|
|
37
|
+
3: 0.5,
|
|
38
|
+
4: 0.5,
|
|
39
|
+
5: 0.5
|
|
40
|
+
};
|
|
41
|
+
ValidationUtils.validateMapInstance(map);
|
|
42
|
+
this.map = map;
|
|
43
|
+
this.eventManager = new EventManager(map);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 添加线要素
|
|
47
|
+
* @param data GeoJSON格式的线数据
|
|
48
|
+
* @param options 配置项
|
|
49
|
+
* @returns 创建的矢量图层
|
|
50
|
+
*/
|
|
51
|
+
addLine(data, options = {}) {
|
|
52
|
+
ValidationUtils.validateGeoJSONData(data);
|
|
53
|
+
const defaultOptions = {
|
|
54
|
+
type: 'line',
|
|
55
|
+
strokeColor: 'rgba(3, 122, 255, 1)',
|
|
56
|
+
strokeWidth: 2,
|
|
57
|
+
visible: true,
|
|
58
|
+
zIndex: 15,
|
|
59
|
+
layerName: options.layerName || 'lineLayer'
|
|
60
|
+
};
|
|
61
|
+
const mergedOptions = { ...defaultOptions, ...options };
|
|
62
|
+
const features = new GeoJSON().readFeatures(data, options.projectionOptOptions);
|
|
63
|
+
const layer = new VectorLayer({
|
|
64
|
+
properties: {
|
|
65
|
+
name: mergedOptions.layerName,
|
|
66
|
+
layerName: mergedOptions.layerName
|
|
67
|
+
},
|
|
68
|
+
source: new VectorSource({ features }),
|
|
69
|
+
style: (feature) => {
|
|
70
|
+
if (feature instanceof Feature) {
|
|
71
|
+
feature.set('type', mergedOptions.type);
|
|
72
|
+
feature.set('layerName', mergedOptions.type);
|
|
73
|
+
}
|
|
74
|
+
return new Style({
|
|
75
|
+
stroke: new Stroke({
|
|
76
|
+
color: mergedOptions.strokeColor,
|
|
77
|
+
width: mergedOptions.strokeWidth,
|
|
78
|
+
lineDash: mergedOptions.lineDash,
|
|
79
|
+
lineDashOffset: mergedOptions.lineDashOffset
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
zIndex: mergedOptions.zIndex
|
|
84
|
+
});
|
|
85
|
+
layer.setVisible(mergedOptions.visible);
|
|
86
|
+
this.map.addLayer(layer);
|
|
87
|
+
return layer;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 添加分级河流图层,根据缩放级别显示不同级别的河流
|
|
91
|
+
* @param fyRiverJson 河流 GeoJSON 数据
|
|
92
|
+
* @param options 河流图层配置选项
|
|
93
|
+
* @throws {Error} 当数据格式无效时抛出错误
|
|
94
|
+
*/
|
|
95
|
+
addRiverLayersByZoom(fyRiverJson, options = {}) {
|
|
96
|
+
ValidationUtils.validateGeoJSONData(fyRiverJson);
|
|
97
|
+
const defaultOptions = {
|
|
98
|
+
type: 'river',
|
|
99
|
+
levelCount: 5,
|
|
100
|
+
zoomOffset: 8,
|
|
101
|
+
strokeColor: 'rgb(0,113,255)',
|
|
102
|
+
strokeWidth: 3,
|
|
103
|
+
visible: true,
|
|
104
|
+
zIndex: 15,
|
|
105
|
+
layerName: 'riverLayer',
|
|
106
|
+
removeExisting: options.removeExisting ?? false,
|
|
107
|
+
levelWidthMap: this.defaultLevelWidthMap
|
|
108
|
+
};
|
|
109
|
+
const mergedOptions = { ...defaultOptions, ...options };
|
|
110
|
+
// 清除现有河流图层
|
|
111
|
+
if (mergedOptions.removeExisting) {
|
|
112
|
+
this.clearRiverLayers();
|
|
113
|
+
}
|
|
114
|
+
this.riverLayerShow = mergedOptions.visible;
|
|
115
|
+
this.riverLayerList = [];
|
|
116
|
+
// 创建分级河流图层
|
|
117
|
+
for (let level = 1; level <= mergedOptions.levelCount; level++) {
|
|
118
|
+
const vectorSource = new VectorSource({
|
|
119
|
+
format: new GeoJSON(),
|
|
120
|
+
loader: () => {
|
|
121
|
+
const geojson = new GeoJSON();
|
|
122
|
+
fyRiverJson.features.forEach((feature) => {
|
|
123
|
+
if (feature.properties && feature.properties.level === level) {
|
|
124
|
+
try {
|
|
125
|
+
const olFeature = geojson.readFeature(feature);
|
|
126
|
+
if (Array.isArray(olFeature)) {
|
|
127
|
+
vectorSource.addFeatures(olFeature);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
vectorSource.addFeature(olFeature);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
console.warn(`Failed to load river feature at level ${level}:`, error);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const riverLayer = new VectorLayer({
|
|
141
|
+
properties: {
|
|
142
|
+
name: mergedOptions.layerName,
|
|
143
|
+
layerName: mergedOptions.layerName,
|
|
144
|
+
riverLevel: level
|
|
145
|
+
},
|
|
146
|
+
source: vectorSource,
|
|
147
|
+
style: (feature) => {
|
|
148
|
+
if (feature instanceof Feature) {
|
|
149
|
+
feature.set('type', mergedOptions.layerName);
|
|
150
|
+
feature.set('layerName', mergedOptions.layerName);
|
|
151
|
+
}
|
|
152
|
+
return new Style({
|
|
153
|
+
stroke: new Stroke({
|
|
154
|
+
color: mergedOptions.strokeColor,
|
|
155
|
+
width: mergedOptions.strokeWidth
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
zIndex: mergedOptions.zIndex
|
|
160
|
+
});
|
|
161
|
+
riverLayer.setVisible(false);
|
|
162
|
+
this.riverLayerList.push(riverLayer);
|
|
163
|
+
this.map.addLayer(riverLayer);
|
|
164
|
+
}
|
|
165
|
+
// 设置缩放事件监听
|
|
166
|
+
this.eventManager.on('moveend', () => {
|
|
167
|
+
this.showRiverLayerByZoom();
|
|
168
|
+
});
|
|
169
|
+
// 初始显示
|
|
170
|
+
this.showRiverLayerByZoom();
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 显示或隐藏河流图层
|
|
174
|
+
* @param show 是否显示河流图层
|
|
175
|
+
*/
|
|
176
|
+
showRiverLayer(show) {
|
|
177
|
+
this.riverLayerShow = show;
|
|
178
|
+
this.showRiverLayerByZoom();
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* 根据缩放级别显示对应的河流图层
|
|
182
|
+
* 缩放级别越高,显示的河流级别越详细
|
|
183
|
+
*/
|
|
184
|
+
showRiverLayerByZoom() {
|
|
185
|
+
const zoom = this.map.getView().getZoom();
|
|
186
|
+
if (!zoom) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this.riverLayerList.forEach((layer, index) => {
|
|
190
|
+
// 计算显示阈值:级别索引 + 1(因为level从1开始)+ 缩放偏移量(默认8)
|
|
191
|
+
const displayThreshold = index + 1 + 8;
|
|
192
|
+
if (zoom > displayThreshold) {
|
|
193
|
+
layer.setVisible(this.riverLayerShow);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
layer.setVisible(false);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* 添加按级别显示不同宽度的河流图层
|
|
202
|
+
* @param data 河流 GeoJSON 数据
|
|
203
|
+
* @param options 河流图层配置选项
|
|
204
|
+
* @returns 创建的河流图层
|
|
205
|
+
*/
|
|
206
|
+
addRiverWidthByLevel(data, options = {}) {
|
|
207
|
+
ValidationUtils.validateGeoJSONData(data);
|
|
208
|
+
// 合并默认配置
|
|
209
|
+
const mergedOptions = {
|
|
210
|
+
type: 'river',
|
|
211
|
+
layerName: 'river',
|
|
212
|
+
strokeColor: 'rgba(3, 122, 255, 1)',
|
|
213
|
+
strokeWidth: 2,
|
|
214
|
+
visible: true,
|
|
215
|
+
zIndex: 15,
|
|
216
|
+
levelWidthMap: this.defaultLevelWidthMap,
|
|
217
|
+
removeExisting: options.removeExisting ?? false,
|
|
218
|
+
...options
|
|
219
|
+
};
|
|
220
|
+
// 移除同名图层(如果存在)
|
|
221
|
+
if (mergedOptions.removeExisting && mergedOptions.layerName) {
|
|
222
|
+
MapTools.removeLayer(this.map, mergedOptions.layerName);
|
|
223
|
+
}
|
|
224
|
+
// 解析 GeoJSON 数据
|
|
225
|
+
const features = new GeoJSON().readFeatures(data, options.projectionOptOptions);
|
|
226
|
+
// 创建河流图层
|
|
227
|
+
const riverLayer = new VectorLayer({
|
|
228
|
+
properties: {
|
|
229
|
+
name: mergedOptions.layerName,
|
|
230
|
+
layerName: mergedOptions.layerName
|
|
231
|
+
},
|
|
232
|
+
source: new VectorSource({ features }),
|
|
233
|
+
style: (feature) => {
|
|
234
|
+
const level = feature.get('level');
|
|
235
|
+
const levelWidth = mergedOptions.levelWidthMap[Number(level)] || 1;
|
|
236
|
+
return new Style({
|
|
237
|
+
stroke: new Stroke({
|
|
238
|
+
color: mergedOptions.strokeColor,
|
|
239
|
+
width: levelWidth
|
|
240
|
+
})
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
zIndex: mergedOptions.zIndex
|
|
244
|
+
});
|
|
245
|
+
riverLayer.setVisible(mergedOptions.visible);
|
|
246
|
+
this.map.addLayer(riverLayer);
|
|
247
|
+
return riverLayer;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* 移除线图层
|
|
251
|
+
* @param layerName 图层名称
|
|
252
|
+
*/
|
|
253
|
+
removeLineLayer(layerName) {
|
|
254
|
+
ValidationUtils.validateLayerName(layerName);
|
|
255
|
+
MapTools.removeLayer(this.map, layerName);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* 清除所有河流图层
|
|
259
|
+
*/
|
|
260
|
+
clearRiverLayers() {
|
|
261
|
+
this.riverLayerList.forEach(layer => {
|
|
262
|
+
this.map.removeLayer(layer);
|
|
263
|
+
});
|
|
264
|
+
this.riverLayerList = [];
|
|
265
|
+
this.riverLayerShow = false;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* 获取河流图层显示状态
|
|
269
|
+
* @returns 河流图层是否显示
|
|
270
|
+
*/
|
|
271
|
+
getRiverLayerVisibility() {
|
|
272
|
+
return this.riverLayerShow;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* 获取河流图层列表
|
|
276
|
+
* @returns 河流图层数组的副本
|
|
277
|
+
*/
|
|
278
|
+
getRiverLayers() {
|
|
279
|
+
return [...this.riverLayerList];
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* 销毁线管理器,清理所有资源
|
|
283
|
+
*/
|
|
284
|
+
destroy() {
|
|
285
|
+
// 清除所有河流图层
|
|
286
|
+
this.clearRiverLayers();
|
|
287
|
+
}
|
|
288
|
+
}
|