my-openlayer 2.4.10 → 2.5.1
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 +167 -265
- package/MyOl.d.ts +9 -9
- package/MyOl.js +17 -16
- package/README.md +217 -156
- package/core/line/Line.d.ts +40 -0
- package/core/line/Line.js +144 -0
- package/core/line/LineFeatureFactory.d.ts +17 -0
- package/core/line/LineFeatureFactory.js +75 -0
- package/core/line/LineFlowAnimator.d.ts +53 -0
- package/core/line/LineFlowAnimator.js +297 -0
- package/core/line/LineStyleFactory.d.ts +43 -0
- package/core/line/LineStyleFactory.js +135 -0
- package/core/{RiverLayerManager.d.ts → line/RiverLayerManager.d.ts} +2 -2
- package/core/{RiverLayerManager.js → line/RiverLayerManager.js} +3 -5
- package/core/line/index.d.ts +6 -0
- package/core/line/index.js +5 -0
- package/core/{ConfigManager.d.ts → map/ConfigManager.d.ts} +25 -1
- package/core/{ConfigManager.js → map/ConfigManager.js} +22 -1
- package/core/{EventManager.d.ts → map/EventManager.d.ts} +1 -1
- package/core/{EventManager.js → map/EventManager.js} +2 -2
- package/core/{MapBaseLayers.d.ts → map/MapBaseLayers.d.ts} +1 -1
- package/core/{MapBaseLayers.js → map/MapBaseLayers.js} +10 -12
- package/core/{MapTools.d.ts → map/MapTools.d.ts} +5 -2
- package/core/{MapTools.js → map/MapTools.js} +11 -5
- package/core/{MeasureHandler.d.ts → map/MeasureHandler.d.ts} +1 -1
- package/core/{MeasureHandler.js → map/MeasureHandler.js} +41 -41
- package/core/map/index.d.ts +5 -0
- package/core/map/index.js +5 -0
- package/core/{Point.d.ts → point/Point.d.ts} +13 -4
- package/core/{Point.js → point/Point.js} +24 -112
- package/core/point/PointClusterLayer.d.ts +10 -0
- package/core/point/PointClusterLayer.js +52 -0
- package/core/point/PointOverlay.d.ts +13 -0
- package/core/point/PointOverlay.js +57 -0
- package/core/point/PointPulseLayer.d.ts +13 -0
- package/core/point/PointPulseLayer.js +207 -0
- package/core/point/index.d.ts +4 -0
- package/core/point/index.js +4 -0
- package/core/{Polygon.d.ts → polygon/Polygon.d.ts} +4 -50
- package/core/polygon/Polygon.js +248 -0
- package/core/polygon/PolygonHeatmapLayer.d.ts +11 -0
- package/core/polygon/PolygonHeatmapLayer.js +40 -0
- package/core/polygon/PolygonImageLayer.d.ts +9 -0
- package/core/polygon/PolygonImageLayer.js +61 -0
- package/core/polygon/PolygonMaskLayer.d.ts +20 -0
- package/core/polygon/PolygonMaskLayer.js +107 -0
- package/core/polygon/PolygonStyleFactory.d.ts +12 -0
- package/core/polygon/PolygonStyleFactory.js +100 -0
- package/core/polygon/index.d.ts +5 -0
- package/core/polygon/index.js +5 -0
- package/core/{SelectHandler.d.ts → select/SelectHandler.d.ts} +2 -3
- package/core/{SelectHandler.js → select/SelectHandler.js} +4 -4
- package/core/select/index.d.ts +1 -0
- package/core/select/index.js +1 -0
- package/core/{VueTemplatePoint.d.ts → vue-template-point/VueTemplatePoint.d.ts} +1 -1
- package/core/{VueTemplatePoint.js → vue-template-point/VueTemplatePoint.js} +4 -4
- package/core/vue-template-point/index.d.ts +1 -0
- package/core/vue-template-point/index.js +1 -0
- 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 +215 -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 +233 -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 +79 -78
- package/index.d.ts +11 -16
- package/index.js +7 -13
- package/package.json +11 -1
- package/types/base.d.ts +47 -0
- package/types/base.js +1 -0
- package/types/common.d.ts +59 -0
- package/types/common.js +1 -0
- package/types/index.d.ts +9 -0
- package/types/index.js +1 -0
- package/types/line.d.ts +41 -0
- package/types/line.js +1 -0
- package/types/map.d.ts +77 -0
- package/types/map.js +1 -0
- package/types/point.d.ts +54 -0
- package/types/point.js +1 -0
- package/types/polygon.d.ts +8 -0
- package/types/polygon.js +1 -0
- package/types/select.d.ts +25 -0
- package/types/select.js +1 -0
- package/types/vue-template-point.d.ts +54 -0
- package/{types.js → types/vue-template-point.js} +0 -3
- package/utils/ProjectionUtils.d.ts +28 -0
- package/utils/ProjectionUtils.js +34 -0
- package/utils/ValidationUtils.d.ts +33 -86
- package/utils/ValidationUtils.js +60 -165
- package/core/DomPoint.d.ts +0 -21
- package/core/DomPoint.js +0 -36
- package/core/Line.d.ts +0 -49
- package/core/Line.js +0 -114
- package/core/Polygon.js +0 -646
- package/docs/.vitepress/cache/deps/@theme_index.js +0 -275
- package/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
- package/docs/.vitepress/cache/deps/_metadata.json +0 -40
- package/docs/.vitepress/cache/deps/chunk-LW4I4DCF.js +0 -12542
- package/docs/.vitepress/cache/deps/chunk-LW4I4DCF.js.map +0 -7
- package/docs/.vitepress/cache/deps/chunk-Z5QSWKN2.js +0 -9719
- package/docs/.vitepress/cache/deps/chunk-Z5QSWKN2.js.map +0 -7
- package/docs/.vitepress/cache/deps/package.json +0 -3
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4505
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -583
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
- package/docs/.vitepress/cache/deps/vue.js +0 -343
- package/docs/.vitepress/cache/deps/vue.js.map +0 -7
- package/types.d.ts +0 -372
package/docs/Polygon.md
CHANGED
|
@@ -1,241 +1,241 @@
|
|
|
1
|
-
# Polygon 面要素类
|
|
2
|
-
|
|
3
|
-
`Polygon` 类用于在地图上绘制面要素、热力图、图片图层和遮罩层,支持丰富的数据可视化功能。
|
|
4
|
-
|
|
5
|
-
## 构造函数
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
const polygon = new Polygon(map: Map);
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
- **map**: OpenLayers 地图实例。
|
|
12
|
-
|
|
13
|
-
## 接口定义
|
|
14
|
-
|
|
15
|
-
### PolygonOptions
|
|
16
|
-
|
|
17
|
-
面图层配置项,继承自 `BaseOptions`, `StyleOptions`, `TextOptions`。
|
|
18
|
-
|
|
19
|
-
| 属性 | 类型 | 说明 |
|
|
20
|
-
| :--- | :--- | :--- |
|
|
21
|
-
| **基础配置** | | |
|
|
22
|
-
| `layerName` | `string` | 图层名称 |
|
|
23
|
-
| `zIndex` | `number` | 图层层级 |
|
|
24
|
-
| `visible` | `boolean` | 是否可见 |
|
|
25
|
-
| `opacity` | `number` | 透明度 (0-1) |
|
|
26
|
-
| `fitView` | `boolean` | 是否自动缩放视图 |
|
|
27
|
-
| **样式配置** | | |
|
|
28
|
-
| `fillColor` | `string` | 填充颜色 |
|
|
29
|
-
| `fillColorCallBack` | `(feature) => string` | 动态填充颜色回调 |
|
|
30
|
-
| `strokeColor` | `string` | 边框颜色 |
|
|
31
|
-
| `strokeWidth` | `number` | 边框宽度 |
|
|
32
|
-
| `lineDash` | `number[]` | 边框虚线样式 |
|
|
33
|
-
| **文本标注** | | |
|
|
34
|
-
| `textVisible` | `boolean` | 是否显示文本 |
|
|
35
|
-
| `textKey` | `string` | 文本对应的属性字段名 |
|
|
36
|
-
| `textCallBack` | `(feature) => string` | 文本回调函数(优先级高于 textKey) |
|
|
37
|
-
| `textFont` | `string` | 字体样式 |
|
|
38
|
-
| `textFillColor` | `string` | 文本颜色 |
|
|
39
|
-
| `textStrokeColor` | `string` | 文本描边颜色 |
|
|
40
|
-
| **其他** | | |
|
|
41
|
-
| `mask` | `boolean` | 是否作为蒙版(配合 `setOutLayer` 使用) |
|
|
42
|
-
|
|
43
|
-
### HeatMapOptions
|
|
44
|
-
|
|
45
|
-
热力图配置项。
|
|
46
|
-
|
|
47
|
-
| 属性 | 类型 | 说明 |
|
|
48
|
-
| :--- | :--- | :--- |
|
|
49
|
-
| `layerName` | `string` | 图层名称 |
|
|
50
|
-
| `radius` | `number` | 热点半径,默认 8 |
|
|
51
|
-
| `blur` | `number` | 模糊度,默认 15 |
|
|
52
|
-
| `gradient` | `string[]` | 颜色渐变数组 |
|
|
53
|
-
| `opacity` | `number` | 透明度 |
|
|
54
|
-
| `valueKey` | `string` | 权重字段名,默认 'value' |
|
|
55
|
-
|
|
56
|
-
### ImageLayerData
|
|
57
|
-
|
|
58
|
-
图片图层数据。
|
|
59
|
-
|
|
60
|
-
| 属性 | 类型 | 说明 |
|
|
61
|
-
| :--- | :--- | :--- |
|
|
62
|
-
| `img` | `string` | 图片 URL |
|
|
63
|
-
| `extent` | `number[]` | 图片覆盖范围 `[minX, minY, maxX, maxY]` |
|
|
64
|
-
|
|
65
|
-
## 方法
|
|
66
|
-
|
|
67
|
-
### addPolygon
|
|
68
|
-
|
|
69
|
-
添加多边形图层。
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
addPolygon(data: MapJSONData, options?: PolygonOptions): VectorLayer<VectorSource>
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
| 参数 | 类型 | 说明 |
|
|
76
|
-
| :--- | :--- | :--- |
|
|
77
|
-
| `data` | `MapJSONData` | GeoJSON 数据 |
|
|
78
|
-
| `options` | `PolygonOptions` | 配置项 |
|
|
79
|
-
|
|
80
|
-
### addPolygonByUrl
|
|
81
|
-
|
|
82
|
-
从 URL 加载多边形图层。
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
addPolygonByUrl(url: string, options?: PolygonOptions): VectorLayer<VectorSource>
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### addBorderPolygon
|
|
89
|
-
|
|
90
|
-
添加边界图层(通常用于行政区划边界,支持镂空效果)。
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
addBorderPolygon(data: MapJSONData, options?: PolygonOptions): VectorLayer<VectorSource>
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### updateFeatureColor
|
|
97
|
-
|
|
98
|
-
动态更新面要素颜色,常用于数据可视化展示。
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
updateFeatureColor(
|
|
102
|
-
layerName: string,
|
|
103
|
-
colorObj?: { [propName: string]: string },
|
|
104
|
-
options?: FeatureColorUpdateOptions
|
|
105
|
-
): void
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
| 参数 | 类型 | 说明 |
|
|
109
|
-
| :--- | :--- | :--- |
|
|
110
|
-
| `layerName` | `string` | 目标图层名称 |
|
|
111
|
-
| `colorObj` | `Object` | 颜色映射对象 `{ '区域名': '颜色值' }` |
|
|
112
|
-
| `options` | `FeatureColorUpdateOptions` | 包含 textKey 等配置以匹配要素 |
|
|
113
|
-
|
|
114
|
-
### addImageLayer
|
|
115
|
-
|
|
116
|
-
添加静态图片图层(如叠加平面图、卫星图)。
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
addImageLayer(imageData: ImageLayerData, options?: PolygonOptions): ImageLayer<any>
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### addHeatmap
|
|
123
|
-
|
|
124
|
-
添加热力图。
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
addHeatmap(pointData: PointData[], options?: HeatMapOptions): Heatmap
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### setOutLayer
|
|
131
|
-
|
|
132
|
-
添加遮罩图层(反向裁剪,只高亮指定区域,遮挡外部)。
|
|
133
|
-
|
|
134
|
-
```typescript
|
|
135
|
-
setOutLayer(data: MapJSONData, options?: {
|
|
136
|
-
layerName?: string,
|
|
137
|
-
extent?: any,
|
|
138
|
-
fillColor?: string,
|
|
139
|
-
strokeWidth?: number,
|
|
140
|
-
strokeColor?: string,
|
|
141
|
-
zIndex?: number
|
|
142
|
-
}): VectorLayer<VectorSource>
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## 使用示例
|
|
146
|
-
|
|
147
|
-
### 基础多边形
|
|
148
|
-
|
|
149
|
-
```typescript
|
|
150
|
-
const polygonModule = map.getPolygon();
|
|
151
|
-
|
|
152
|
-
// GeoJSON 数据
|
|
153
|
-
const polygonData = {
|
|
154
|
-
type: 'FeatureCollection',
|
|
155
|
-
features: [
|
|
156
|
-
{
|
|
157
|
-
type: 'Feature',
|
|
158
|
-
geometry: {
|
|
159
|
-
type: 'Polygon',
|
|
160
|
-
coordinates: [[[120, 30], [121, 30], [121, 31], [120, 31], [120, 30]]]
|
|
161
|
-
},
|
|
162
|
-
properties: { name: '区域A', value: 100 }
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
// 添加半透明蓝色填充、蓝色边框的多边形
|
|
168
|
-
polygonModule.addPolygon(polygonData, {
|
|
169
|
-
layerName: 'area-layer',
|
|
170
|
-
fillColor: 'rgba(0, 0, 255, 0.1)',
|
|
171
|
-
strokeColor: 'blue',
|
|
172
|
-
strokeWidth: 2,
|
|
173
|
-
textKey: 'name', // 显示名称
|
|
174
|
-
textFillColor: '#fff',
|
|
175
|
-
textStrokeColor: 'blue',
|
|
176
|
-
textStrokeWidth: 2,
|
|
177
|
-
fitView: true
|
|
178
|
-
});
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### 数据可视化(动态填色)
|
|
182
|
-
|
|
183
|
-
```typescript
|
|
184
|
-
// 假设 'area-layer' 中的要素有 'name' 属性
|
|
185
|
-
// 我们将 '区域A' 设为红色,其他区域保持默认或设为其他颜色
|
|
186
|
-
polygonModule.updateFeatureColor(
|
|
187
|
-
'area-layer',
|
|
188
|
-
{
|
|
189
|
-
'区域A': 'rgba(255, 0, 0, 0.5)',
|
|
190
|
-
'区域B': 'rgba(0, 255, 0, 0.5)'
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
textKey: 'name', // 匹配 colorObj 的键
|
|
194
|
-
strokeColor: '#666', // 统一更新边框颜色
|
|
195
|
-
strokeWidth: 1
|
|
196
|
-
}
|
|
197
|
-
);
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### 热力图
|
|
201
|
-
|
|
202
|
-
```typescript
|
|
203
|
-
const heatPoints = [
|
|
204
|
-
{ lgtd: 119.8, lttd: 29.9, value: 100 },
|
|
205
|
-
{ lgtd: 119.9, lttd: 30.0, value: 50 },
|
|
206
|
-
// ... 更多点
|
|
207
|
-
];
|
|
208
|
-
|
|
209
|
-
polygonModule.addHeatmap(heatPoints, {
|
|
210
|
-
layerName: 'heatmap-layer',
|
|
211
|
-
radius: 20, // 热点半径
|
|
212
|
-
blur: 15, // 边缘模糊
|
|
213
|
-
valueKey: 'value', // 权重字段
|
|
214
|
-
gradient: ['#00f', '#0ff', '#0f0', '#ff0', '#f00'] // 自定义渐变色
|
|
215
|
-
});
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
### 图片图层
|
|
219
|
-
|
|
220
|
-
```typescript
|
|
221
|
-
// 将图片叠加到指定经纬度范围
|
|
222
|
-
polygonModule.addImageLayer({
|
|
223
|
-
img: 'https://example.com/plan.png',
|
|
224
|
-
extent: [120.0, 30.0, 120.1, 30.1] // [minX, minY, maxX, maxY]
|
|
225
|
-
}, {
|
|
226
|
-
layerName: 'image-overlay',
|
|
227
|
-
opacity: 0.8
|
|
228
|
-
});
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### 遮罩层(反向裁剪)
|
|
232
|
-
|
|
233
|
-
```typescript
|
|
234
|
-
// 添加遮罩,除了 polygonData 覆盖的区域外,其他区域都会被遮挡
|
|
235
|
-
polygonModule.setOutLayer(polygonData, {
|
|
236
|
-
layerName: 'mask-layer',
|
|
237
|
-
fillColor: 'rgba(0, 0, 0, 0.5)', // 黑色半透明遮罩
|
|
238
|
-
strokeColor: '#fff',
|
|
239
|
-
strokeWidth: 2
|
|
240
|
-
});
|
|
241
|
-
```
|
|
1
|
+
# Polygon 面要素类
|
|
2
|
+
|
|
3
|
+
`Polygon` 类用于在地图上绘制面要素、热力图、图片图层和遮罩层,支持丰富的数据可视化功能。
|
|
4
|
+
|
|
5
|
+
## 构造函数
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
const polygon = new Polygon(map: Map);
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
- **map**: OpenLayers 地图实例。
|
|
12
|
+
|
|
13
|
+
## 接口定义
|
|
14
|
+
|
|
15
|
+
### PolygonOptions
|
|
16
|
+
|
|
17
|
+
面图层配置项,继承自 `BaseOptions`, `StyleOptions`, `TextOptions`。
|
|
18
|
+
|
|
19
|
+
| 属性 | 类型 | 说明 |
|
|
20
|
+
| :--- | :--- | :--- |
|
|
21
|
+
| **基础配置** | | |
|
|
22
|
+
| `layerName` | `string` | 图层名称 |
|
|
23
|
+
| `zIndex` | `number` | 图层层级 |
|
|
24
|
+
| `visible` | `boolean` | 是否可见 |
|
|
25
|
+
| `opacity` | `number` | 透明度 (0-1) |
|
|
26
|
+
| `fitView` | `boolean` | 是否自动缩放视图 |
|
|
27
|
+
| **样式配置** | | |
|
|
28
|
+
| `fillColor` | `string` | 填充颜色 |
|
|
29
|
+
| `fillColorCallBack` | `(feature) => string` | 动态填充颜色回调 |
|
|
30
|
+
| `strokeColor` | `string` | 边框颜色 |
|
|
31
|
+
| `strokeWidth` | `number` | 边框宽度 |
|
|
32
|
+
| `lineDash` | `number[]` | 边框虚线样式 |
|
|
33
|
+
| **文本标注** | | |
|
|
34
|
+
| `textVisible` | `boolean` | 是否显示文本 |
|
|
35
|
+
| `textKey` | `string` | 文本对应的属性字段名 |
|
|
36
|
+
| `textCallBack` | `(feature) => string` | 文本回调函数(优先级高于 textKey) |
|
|
37
|
+
| `textFont` | `string` | 字体样式 |
|
|
38
|
+
| `textFillColor` | `string` | 文本颜色 |
|
|
39
|
+
| `textStrokeColor` | `string` | 文本描边颜色 |
|
|
40
|
+
| **其他** | | |
|
|
41
|
+
| `mask` | `boolean` | 是否作为蒙版(配合 `setOutLayer` 使用) |
|
|
42
|
+
|
|
43
|
+
### HeatMapOptions
|
|
44
|
+
|
|
45
|
+
热力图配置项。
|
|
46
|
+
|
|
47
|
+
| 属性 | 类型 | 说明 |
|
|
48
|
+
| :--- | :--- | :--- |
|
|
49
|
+
| `layerName` | `string` | 图层名称 |
|
|
50
|
+
| `radius` | `number` | 热点半径,默认 8 |
|
|
51
|
+
| `blur` | `number` | 模糊度,默认 15 |
|
|
52
|
+
| `gradient` | `string[]` | 颜色渐变数组 |
|
|
53
|
+
| `opacity` | `number` | 透明度 |
|
|
54
|
+
| `valueKey` | `string` | 权重字段名,默认 'value' |
|
|
55
|
+
|
|
56
|
+
### ImageLayerData
|
|
57
|
+
|
|
58
|
+
图片图层数据。
|
|
59
|
+
|
|
60
|
+
| 属性 | 类型 | 说明 |
|
|
61
|
+
| :--- | :--- | :--- |
|
|
62
|
+
| `img` | `string` | 图片 URL |
|
|
63
|
+
| `extent` | `number[]` | 图片覆盖范围 `[minX, minY, maxX, maxY]` |
|
|
64
|
+
|
|
65
|
+
## 方法
|
|
66
|
+
|
|
67
|
+
### addPolygon
|
|
68
|
+
|
|
69
|
+
添加多边形图层。
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
addPolygon(data: MapJSONData, options?: PolygonOptions): VectorLayer<VectorSource>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
| 参数 | 类型 | 说明 |
|
|
76
|
+
| :--- | :--- | :--- |
|
|
77
|
+
| `data` | `MapJSONData` | GeoJSON 数据 |
|
|
78
|
+
| `options` | `PolygonOptions` | 配置项 |
|
|
79
|
+
|
|
80
|
+
### addPolygonByUrl
|
|
81
|
+
|
|
82
|
+
从 URL 加载多边形图层。
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
addPolygonByUrl(url: string, options?: PolygonOptions): VectorLayer<VectorSource>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### addBorderPolygon
|
|
89
|
+
|
|
90
|
+
添加边界图层(通常用于行政区划边界,支持镂空效果)。
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
addBorderPolygon(data: MapJSONData, options?: PolygonOptions): VectorLayer<VectorSource>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### updateFeatureColor
|
|
97
|
+
|
|
98
|
+
动态更新面要素颜色,常用于数据可视化展示。
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
updateFeatureColor(
|
|
102
|
+
layerName: string,
|
|
103
|
+
colorObj?: { [propName: string]: string },
|
|
104
|
+
options?: FeatureColorUpdateOptions
|
|
105
|
+
): void
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
| 参数 | 类型 | 说明 |
|
|
109
|
+
| :--- | :--- | :--- |
|
|
110
|
+
| `layerName` | `string` | 目标图层名称 |
|
|
111
|
+
| `colorObj` | `Object` | 颜色映射对象 `{ '区域名': '颜色值' }` |
|
|
112
|
+
| `options` | `FeatureColorUpdateOptions` | 包含 textKey 等配置以匹配要素 |
|
|
113
|
+
|
|
114
|
+
### addImageLayer
|
|
115
|
+
|
|
116
|
+
添加静态图片图层(如叠加平面图、卫星图)。
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
addImageLayer(imageData: ImageLayerData, options?: PolygonOptions): ImageLayer<any>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### addHeatmap
|
|
123
|
+
|
|
124
|
+
添加热力图。
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
addHeatmap(pointData: PointData[], options?: HeatMapOptions): Heatmap
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### setOutLayer
|
|
131
|
+
|
|
132
|
+
添加遮罩图层(反向裁剪,只高亮指定区域,遮挡外部)。
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
setOutLayer(data: MapJSONData, options?: {
|
|
136
|
+
layerName?: string,
|
|
137
|
+
extent?: any,
|
|
138
|
+
fillColor?: string,
|
|
139
|
+
strokeWidth?: number,
|
|
140
|
+
strokeColor?: string,
|
|
141
|
+
zIndex?: number
|
|
142
|
+
}): VectorLayer<VectorSource>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## 使用示例
|
|
146
|
+
|
|
147
|
+
### 基础多边形
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const polygonModule = map.getPolygon();
|
|
151
|
+
|
|
152
|
+
// GeoJSON 数据
|
|
153
|
+
const polygonData = {
|
|
154
|
+
type: 'FeatureCollection',
|
|
155
|
+
features: [
|
|
156
|
+
{
|
|
157
|
+
type: 'Feature',
|
|
158
|
+
geometry: {
|
|
159
|
+
type: 'Polygon',
|
|
160
|
+
coordinates: [[[120, 30], [121, 30], [121, 31], [120, 31], [120, 30]]]
|
|
161
|
+
},
|
|
162
|
+
properties: { name: '区域A', value: 100 }
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// 添加半透明蓝色填充、蓝色边框的多边形
|
|
168
|
+
polygonModule.addPolygon(polygonData, {
|
|
169
|
+
layerName: 'area-layer',
|
|
170
|
+
fillColor: 'rgba(0, 0, 255, 0.1)',
|
|
171
|
+
strokeColor: 'blue',
|
|
172
|
+
strokeWidth: 2,
|
|
173
|
+
textKey: 'name', // 显示名称
|
|
174
|
+
textFillColor: '#fff',
|
|
175
|
+
textStrokeColor: 'blue',
|
|
176
|
+
textStrokeWidth: 2,
|
|
177
|
+
fitView: true
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 数据可视化(动态填色)
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// 假设 'area-layer' 中的要素有 'name' 属性
|
|
185
|
+
// 我们将 '区域A' 设为红色,其他区域保持默认或设为其他颜色
|
|
186
|
+
polygonModule.updateFeatureColor(
|
|
187
|
+
'area-layer',
|
|
188
|
+
{
|
|
189
|
+
'区域A': 'rgba(255, 0, 0, 0.5)',
|
|
190
|
+
'区域B': 'rgba(0, 255, 0, 0.5)'
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
textKey: 'name', // 匹配 colorObj 的键
|
|
194
|
+
strokeColor: '#666', // 统一更新边框颜色
|
|
195
|
+
strokeWidth: 1
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 热力图
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
const heatPoints = [
|
|
204
|
+
{ lgtd: 119.8, lttd: 29.9, value: 100 },
|
|
205
|
+
{ lgtd: 119.9, lttd: 30.0, value: 50 },
|
|
206
|
+
// ... 更多点
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
polygonModule.addHeatmap(heatPoints, {
|
|
210
|
+
layerName: 'heatmap-layer',
|
|
211
|
+
radius: 20, // 热点半径
|
|
212
|
+
blur: 15, // 边缘模糊
|
|
213
|
+
valueKey: 'value', // 权重字段
|
|
214
|
+
gradient: ['#00f', '#0ff', '#0f0', '#ff0', '#f00'] // 自定义渐变色
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 图片图层
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
// 将图片叠加到指定经纬度范围
|
|
222
|
+
polygonModule.addImageLayer({
|
|
223
|
+
img: 'https://example.com/plan.png',
|
|
224
|
+
extent: [120.0, 30.0, 120.1, 30.1] // [minX, minY, maxX, maxY]
|
|
225
|
+
}, {
|
|
226
|
+
layerName: 'image-overlay',
|
|
227
|
+
opacity: 0.8
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 遮罩层(反向裁剪)
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
// 添加遮罩,除了 polygonData 覆盖的区域外,其他区域都会被遮挡
|
|
235
|
+
polygonModule.setOutLayer(polygonData, {
|
|
236
|
+
layerName: 'mask-layer',
|
|
237
|
+
fillColor: 'rgba(0, 0, 0, 0.5)', // 黑色半透明遮罩
|
|
238
|
+
strokeColor: '#fff',
|
|
239
|
+
strokeWidth: 2
|
|
240
|
+
});
|
|
241
|
+
```
|