my-openlayer 2.4.8 → 2.4.9
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/CHANGELOG.md +207 -151
- package/README.md +156 -156
- package/core/Point.js +21 -3
- package/docs/.vitepress/config.mts +57 -57
- package/docs/ConfigManager.md +71 -71
- package/docs/ErrorHandler.md +106 -106
- package/docs/EventManager.md +142 -142
- package/docs/Line.md +187 -187
- package/docs/MapBaseLayers.md +198 -198
- package/docs/MapTools.md +172 -172
- package/docs/MeasureHandler.md +87 -87
- package/docs/MyOl.md +247 -247
- package/docs/Point.md +165 -165
- package/docs/Polygon.md +241 -241
- package/docs/RiverLayerManager.md +187 -187
- package/docs/SelectHandler.md +147 -147
- package/docs/ValidationUtils.md +83 -83
- package/docs/VueTemplatePoint.md +214 -214
- package/docs/index.md +78 -78
- package/package.json +1 -2
- package/types.d.ts +2 -0
- package/AI_CONTEXT.md +0 -147
package/docs/MapBaseLayers.md
CHANGED
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
# MapBaseLayers 底图管理类
|
|
2
|
-
|
|
3
|
-
`MapBaseLayers` 用于管理地图底图(如天地图、自定义切片)和注记图层,支持图层切换、WMS 图层加载和图层状态管理。
|
|
4
|
-
|
|
5
|
-
## 构造函数
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
// 通常通过 MyOl 实例内部初始化,或者手动创建
|
|
9
|
-
const baseLayers = new MapBaseLayers(map: Map, options: MapLayersOptions);
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
- **map**: OpenLayers 地图实例。
|
|
13
|
-
- **options**: 图层配置选项。
|
|
14
|
-
|
|
15
|
-
## 接口定义
|
|
16
|
-
|
|
17
|
-
### MapLayersOptions
|
|
18
|
-
|
|
19
|
-
初始化时的图层配置。
|
|
20
|
-
|
|
21
|
-
| 属性 | 类型 | 说明 |
|
|
22
|
-
| :--- | :--- | :--- |
|
|
23
|
-
| `layers` | `Layer[]` \| `Object` | 底图配置。如果是数组,视为自定义底图;如果是对象,键为类型,值为图层数组。 |
|
|
24
|
-
| `token` | `string` | 天地图 Token(如果使用内置天地图逻辑) |
|
|
25
|
-
| `annotation` | `boolean` | 是否初始化注记图层 |
|
|
26
|
-
| `zIndex` | `number` | 基础层级,默认 0 |
|
|
27
|
-
| `mapClip` | `boolean` | 是否启用地图裁剪 |
|
|
28
|
-
| `mapClipData` | `MapJSONData` | 裁剪数据 |
|
|
29
|
-
|
|
30
|
-
### AnnotationLayerOptions
|
|
31
|
-
|
|
32
|
-
注记图层配置。
|
|
33
|
-
|
|
34
|
-
| 属性 | 类型 | 说明 |
|
|
35
|
-
| :--- | :--- | :--- |
|
|
36
|
-
| `type` | `string` | 注记类型:`cva_c` (矢量注记), `cia_c` (影像注记), `cta_c` (地形注记) |
|
|
37
|
-
| `token` | `string` | 天地图 Token |
|
|
38
|
-
| `zIndex` | `number` | 图层层级 |
|
|
39
|
-
| `visible` | `boolean` | 是否可见 |
|
|
40
|
-
|
|
41
|
-
### GeoServerLayerOptions
|
|
42
|
-
|
|
43
|
-
GeoServer WMS 图层配置。
|
|
44
|
-
|
|
45
|
-
| 属性 | 类型 | 说明 |
|
|
46
|
-
| :--- | :--- | :--- |
|
|
47
|
-
| `zIndex` | `number` | 图层层级 |
|
|
48
|
-
| `visible` | `boolean` | 是否可见 |
|
|
49
|
-
| `version` | `'1.1.1' \| '1.3.0'` | WMS 版本 |
|
|
50
|
-
| `serverType` | `string` | 服务器类型,如 `'geoserver'` |
|
|
51
|
-
| `crossOrigin` | `string` | 跨域设置,默认 `'anonymous'` |
|
|
52
|
-
| `params` | `Object` | 额外的 WMS 参数 |
|
|
53
|
-
|
|
54
|
-
## 方法
|
|
55
|
-
|
|
56
|
-
### 底图操作
|
|
57
|
-
|
|
58
|
-
#### switchBaseLayer
|
|
59
|
-
|
|
60
|
-
切换底图类型(如 `vec_c`, `img_c`, `ter_c`)。
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
switchBaseLayer(type: string): this
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
#### getCurrentBaseLayerType
|
|
67
|
-
|
|
68
|
-
获取当前底图类型。
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
getCurrentBaseLayerType(): string | null
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
#### removeLayersByType
|
|
75
|
-
|
|
76
|
-
移除指定类型的图层。
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
removeLayersByType(type: string): this
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
#### clearAllLayers
|
|
83
|
-
|
|
84
|
-
清除所有底图和注记图层。
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
clearAllLayers(): this
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### 注记操作
|
|
91
|
-
|
|
92
|
-
#### addAnnotationLayer
|
|
93
|
-
|
|
94
|
-
添加注记图层。
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
addAnnotationLayer(options: Omit<AnnotationLayerOptions, 'token'>): TileLayer<XYZ>
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
#### switchAnnotationLayer
|
|
101
|
-
|
|
102
|
-
切换注记类型。
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
switchAnnotationLayer(annotationType: AnnotationType): this
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
#### setAnnotationVisible
|
|
109
|
-
|
|
110
|
-
设置注记图层可见性。
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
setAnnotationVisible(visible: boolean): this
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
#### isAnnotationVisible
|
|
117
|
-
|
|
118
|
-
检查注记图层是否可见。
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
isAnnotationVisible(): boolean
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### 高级图层
|
|
125
|
-
|
|
126
|
-
#### addGeoServerLayer
|
|
127
|
-
|
|
128
|
-
添加 GeoServer WMS 图层。
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
addGeoServerLayer(url: string, layerName: string, options?: GeoServerLayerOptions): TileLayer<TileWMS>
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
| 参数 | 类型 | 说明 |
|
|
135
|
-
| :--- | :--- | :--- |
|
|
136
|
-
| `url` | `string` | WMS 服务地址 |
|
|
137
|
-
| `layerName` | `string` | WMS 图层名称 |
|
|
138
|
-
| `options` | `GeoServerLayerOptions` | 配置项 |
|
|
139
|
-
|
|
140
|
-
#### getLayerStats
|
|
141
|
-
|
|
142
|
-
获取图层数量统计。
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
getLayerStats(): { totalTypes: number; totalLayers: number; layersByType: Record<string, number> }
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## 使用示例
|
|
149
|
-
|
|
150
|
-
### 切换天地图底图
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
const baseLayers = map.getMapBaseLayers();
|
|
154
|
-
|
|
155
|
-
// 切换到影像底图 (img_c)
|
|
156
|
-
baseLayers.switchBaseLayer('img_c');
|
|
157
|
-
|
|
158
|
-
// 切换回矢量底图 (vec_c)
|
|
159
|
-
baseLayers.switchBaseLayer('vec_c');
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### 管理注记图层
|
|
163
|
-
|
|
164
|
-
```typescript
|
|
165
|
-
// 隐藏注记
|
|
166
|
-
baseLayers.setAnnotationVisible(false);
|
|
167
|
-
|
|
168
|
-
// 切换为影像注记 (cia_c)
|
|
169
|
-
baseLayers.switchAnnotationLayer('cia_c');
|
|
170
|
-
|
|
171
|
-
// 显示注记
|
|
172
|
-
baseLayers.setAnnotationVisible(true);
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### 加载 GeoServer WMS 图层
|
|
176
|
-
|
|
177
|
-
```typescript
|
|
178
|
-
// 添加一个 WMS 图层
|
|
179
|
-
const wmsLayer = baseLayers.addGeoServerLayer(
|
|
180
|
-
'http://localhost:8080/geoserver/wms',
|
|
181
|
-
'myworkspace:mylayer',
|
|
182
|
-
{
|
|
183
|
-
visible: true,
|
|
184
|
-
zIndex: 10,
|
|
185
|
-
params: {
|
|
186
|
-
'CQL_FILTER': "status = 'active'" // 可选:传递自定义参数
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
);
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### 图层统计
|
|
193
|
-
|
|
194
|
-
```typescript
|
|
195
|
-
const stats = baseLayers.getLayerStats();
|
|
196
|
-
console.log(`总图层数: ${stats.totalLayers}`);
|
|
197
|
-
console.log('各类型图层数:', stats.layersByType);
|
|
198
|
-
```
|
|
1
|
+
# MapBaseLayers 底图管理类
|
|
2
|
+
|
|
3
|
+
`MapBaseLayers` 用于管理地图底图(如天地图、自定义切片)和注记图层,支持图层切换、WMS 图层加载和图层状态管理。
|
|
4
|
+
|
|
5
|
+
## 构造函数
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// 通常通过 MyOl 实例内部初始化,或者手动创建
|
|
9
|
+
const baseLayers = new MapBaseLayers(map: Map, options: MapLayersOptions);
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
- **map**: OpenLayers 地图实例。
|
|
13
|
+
- **options**: 图层配置选项。
|
|
14
|
+
|
|
15
|
+
## 接口定义
|
|
16
|
+
|
|
17
|
+
### MapLayersOptions
|
|
18
|
+
|
|
19
|
+
初始化时的图层配置。
|
|
20
|
+
|
|
21
|
+
| 属性 | 类型 | 说明 |
|
|
22
|
+
| :--- | :--- | :--- |
|
|
23
|
+
| `layers` | `Layer[]` \| `Object` | 底图配置。如果是数组,视为自定义底图;如果是对象,键为类型,值为图层数组。 |
|
|
24
|
+
| `token` | `string` | 天地图 Token(如果使用内置天地图逻辑) |
|
|
25
|
+
| `annotation` | `boolean` | 是否初始化注记图层 |
|
|
26
|
+
| `zIndex` | `number` | 基础层级,默认 0 |
|
|
27
|
+
| `mapClip` | `boolean` | 是否启用地图裁剪 |
|
|
28
|
+
| `mapClipData` | `MapJSONData` | 裁剪数据 |
|
|
29
|
+
|
|
30
|
+
### AnnotationLayerOptions
|
|
31
|
+
|
|
32
|
+
注记图层配置。
|
|
33
|
+
|
|
34
|
+
| 属性 | 类型 | 说明 |
|
|
35
|
+
| :--- | :--- | :--- |
|
|
36
|
+
| `type` | `string` | 注记类型:`cva_c` (矢量注记), `cia_c` (影像注记), `cta_c` (地形注记) |
|
|
37
|
+
| `token` | `string` | 天地图 Token |
|
|
38
|
+
| `zIndex` | `number` | 图层层级 |
|
|
39
|
+
| `visible` | `boolean` | 是否可见 |
|
|
40
|
+
|
|
41
|
+
### GeoServerLayerOptions
|
|
42
|
+
|
|
43
|
+
GeoServer WMS 图层配置。
|
|
44
|
+
|
|
45
|
+
| 属性 | 类型 | 说明 |
|
|
46
|
+
| :--- | :--- | :--- |
|
|
47
|
+
| `zIndex` | `number` | 图层层级 |
|
|
48
|
+
| `visible` | `boolean` | 是否可见 |
|
|
49
|
+
| `version` | `'1.1.1' \| '1.3.0'` | WMS 版本 |
|
|
50
|
+
| `serverType` | `string` | 服务器类型,如 `'geoserver'` |
|
|
51
|
+
| `crossOrigin` | `string` | 跨域设置,默认 `'anonymous'` |
|
|
52
|
+
| `params` | `Object` | 额外的 WMS 参数 |
|
|
53
|
+
|
|
54
|
+
## 方法
|
|
55
|
+
|
|
56
|
+
### 底图操作
|
|
57
|
+
|
|
58
|
+
#### switchBaseLayer
|
|
59
|
+
|
|
60
|
+
切换底图类型(如 `vec_c`, `img_c`, `ter_c`)。
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
switchBaseLayer(type: string): this
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### getCurrentBaseLayerType
|
|
67
|
+
|
|
68
|
+
获取当前底图类型。
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
getCurrentBaseLayerType(): string | null
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### removeLayersByType
|
|
75
|
+
|
|
76
|
+
移除指定类型的图层。
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
removeLayersByType(type: string): this
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### clearAllLayers
|
|
83
|
+
|
|
84
|
+
清除所有底图和注记图层。
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
clearAllLayers(): this
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 注记操作
|
|
91
|
+
|
|
92
|
+
#### addAnnotationLayer
|
|
93
|
+
|
|
94
|
+
添加注记图层。
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
addAnnotationLayer(options: Omit<AnnotationLayerOptions, 'token'>): TileLayer<XYZ>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### switchAnnotationLayer
|
|
101
|
+
|
|
102
|
+
切换注记类型。
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
switchAnnotationLayer(annotationType: AnnotationType): this
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### setAnnotationVisible
|
|
109
|
+
|
|
110
|
+
设置注记图层可见性。
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
setAnnotationVisible(visible: boolean): this
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### isAnnotationVisible
|
|
117
|
+
|
|
118
|
+
检查注记图层是否可见。
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
isAnnotationVisible(): boolean
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 高级图层
|
|
125
|
+
|
|
126
|
+
#### addGeoServerLayer
|
|
127
|
+
|
|
128
|
+
添加 GeoServer WMS 图层。
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
addGeoServerLayer(url: string, layerName: string, options?: GeoServerLayerOptions): TileLayer<TileWMS>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
| 参数 | 类型 | 说明 |
|
|
135
|
+
| :--- | :--- | :--- |
|
|
136
|
+
| `url` | `string` | WMS 服务地址 |
|
|
137
|
+
| `layerName` | `string` | WMS 图层名称 |
|
|
138
|
+
| `options` | `GeoServerLayerOptions` | 配置项 |
|
|
139
|
+
|
|
140
|
+
#### getLayerStats
|
|
141
|
+
|
|
142
|
+
获取图层数量统计。
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
getLayerStats(): { totalTypes: number; totalLayers: number; layersByType: Record<string, number> }
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## 使用示例
|
|
149
|
+
|
|
150
|
+
### 切换天地图底图
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
const baseLayers = map.getMapBaseLayers();
|
|
154
|
+
|
|
155
|
+
// 切换到影像底图 (img_c)
|
|
156
|
+
baseLayers.switchBaseLayer('img_c');
|
|
157
|
+
|
|
158
|
+
// 切换回矢量底图 (vec_c)
|
|
159
|
+
baseLayers.switchBaseLayer('vec_c');
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 管理注记图层
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
// 隐藏注记
|
|
166
|
+
baseLayers.setAnnotationVisible(false);
|
|
167
|
+
|
|
168
|
+
// 切换为影像注记 (cia_c)
|
|
169
|
+
baseLayers.switchAnnotationLayer('cia_c');
|
|
170
|
+
|
|
171
|
+
// 显示注记
|
|
172
|
+
baseLayers.setAnnotationVisible(true);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 加载 GeoServer WMS 图层
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
// 添加一个 WMS 图层
|
|
179
|
+
const wmsLayer = baseLayers.addGeoServerLayer(
|
|
180
|
+
'http://localhost:8080/geoserver/wms',
|
|
181
|
+
'myworkspace:mylayer',
|
|
182
|
+
{
|
|
183
|
+
visible: true,
|
|
184
|
+
zIndex: 10,
|
|
185
|
+
params: {
|
|
186
|
+
'CQL_FILTER': "status = 'active'" // 可选:传递自定义参数
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 图层统计
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
const stats = baseLayers.getLayerStats();
|
|
196
|
+
console.log(`总图层数: ${stats.totalLayers}`);
|
|
197
|
+
console.log('各类型图层数:', stats.layersByType);
|
|
198
|
+
```
|