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.
Files changed (119) hide show
  1. package/CHANGELOG.md +167 -265
  2. package/MyOl.d.ts +9 -9
  3. package/MyOl.js +17 -16
  4. package/README.md +217 -156
  5. package/core/line/Line.d.ts +40 -0
  6. package/core/line/Line.js +144 -0
  7. package/core/line/LineFeatureFactory.d.ts +17 -0
  8. package/core/line/LineFeatureFactory.js +75 -0
  9. package/core/line/LineFlowAnimator.d.ts +53 -0
  10. package/core/line/LineFlowAnimator.js +297 -0
  11. package/core/line/LineStyleFactory.d.ts +43 -0
  12. package/core/line/LineStyleFactory.js +135 -0
  13. package/core/{RiverLayerManager.d.ts → line/RiverLayerManager.d.ts} +2 -2
  14. package/core/{RiverLayerManager.js → line/RiverLayerManager.js} +3 -5
  15. package/core/line/index.d.ts +6 -0
  16. package/core/line/index.js +5 -0
  17. package/core/{ConfigManager.d.ts → map/ConfigManager.d.ts} +25 -1
  18. package/core/{ConfigManager.js → map/ConfigManager.js} +22 -1
  19. package/core/{EventManager.d.ts → map/EventManager.d.ts} +1 -1
  20. package/core/{EventManager.js → map/EventManager.js} +2 -2
  21. package/core/{MapBaseLayers.d.ts → map/MapBaseLayers.d.ts} +1 -1
  22. package/core/{MapBaseLayers.js → map/MapBaseLayers.js} +10 -12
  23. package/core/{MapTools.d.ts → map/MapTools.d.ts} +5 -2
  24. package/core/{MapTools.js → map/MapTools.js} +11 -5
  25. package/core/{MeasureHandler.d.ts → map/MeasureHandler.d.ts} +1 -1
  26. package/core/{MeasureHandler.js → map/MeasureHandler.js} +41 -41
  27. package/core/map/index.d.ts +5 -0
  28. package/core/map/index.js +5 -0
  29. package/core/{Point.d.ts → point/Point.d.ts} +13 -4
  30. package/core/{Point.js → point/Point.js} +24 -112
  31. package/core/point/PointClusterLayer.d.ts +10 -0
  32. package/core/point/PointClusterLayer.js +52 -0
  33. package/core/point/PointOverlay.d.ts +13 -0
  34. package/core/point/PointOverlay.js +57 -0
  35. package/core/point/PointPulseLayer.d.ts +13 -0
  36. package/core/point/PointPulseLayer.js +207 -0
  37. package/core/point/index.d.ts +4 -0
  38. package/core/point/index.js +4 -0
  39. package/core/{Polygon.d.ts → polygon/Polygon.d.ts} +4 -50
  40. package/core/polygon/Polygon.js +248 -0
  41. package/core/polygon/PolygonHeatmapLayer.d.ts +11 -0
  42. package/core/polygon/PolygonHeatmapLayer.js +40 -0
  43. package/core/polygon/PolygonImageLayer.d.ts +9 -0
  44. package/core/polygon/PolygonImageLayer.js +61 -0
  45. package/core/polygon/PolygonMaskLayer.d.ts +20 -0
  46. package/core/polygon/PolygonMaskLayer.js +107 -0
  47. package/core/polygon/PolygonStyleFactory.d.ts +12 -0
  48. package/core/polygon/PolygonStyleFactory.js +100 -0
  49. package/core/polygon/index.d.ts +5 -0
  50. package/core/polygon/index.js +5 -0
  51. package/core/{SelectHandler.d.ts → select/SelectHandler.d.ts} +2 -3
  52. package/core/{SelectHandler.js → select/SelectHandler.js} +4 -4
  53. package/core/select/index.d.ts +1 -0
  54. package/core/select/index.js +1 -0
  55. package/core/{VueTemplatePoint.d.ts → vue-template-point/VueTemplatePoint.d.ts} +1 -1
  56. package/core/{VueTemplatePoint.js → vue-template-point/VueTemplatePoint.js} +4 -4
  57. package/core/vue-template-point/index.d.ts +1 -0
  58. package/core/vue-template-point/index.js +1 -0
  59. package/docs/.vitepress/config.mts +57 -57
  60. package/docs/ConfigManager.md +71 -71
  61. package/docs/ErrorHandler.md +106 -106
  62. package/docs/EventManager.md +142 -142
  63. package/docs/Line.md +215 -187
  64. package/docs/MapBaseLayers.md +198 -198
  65. package/docs/MapTools.md +172 -172
  66. package/docs/MeasureHandler.md +87 -87
  67. package/docs/MyOl.md +247 -247
  68. package/docs/Point.md +233 -165
  69. package/docs/Polygon.md +241 -241
  70. package/docs/RiverLayerManager.md +187 -187
  71. package/docs/SelectHandler.md +147 -147
  72. package/docs/ValidationUtils.md +83 -83
  73. package/docs/VueTemplatePoint.md +214 -214
  74. package/docs/index.md +79 -78
  75. package/index.d.ts +11 -16
  76. package/index.js +7 -13
  77. package/package.json +11 -1
  78. package/types/base.d.ts +47 -0
  79. package/types/base.js +1 -0
  80. package/types/common.d.ts +59 -0
  81. package/types/common.js +1 -0
  82. package/types/index.d.ts +9 -0
  83. package/types/index.js +1 -0
  84. package/types/line.d.ts +41 -0
  85. package/types/line.js +1 -0
  86. package/types/map.d.ts +77 -0
  87. package/types/map.js +1 -0
  88. package/types/point.d.ts +54 -0
  89. package/types/point.js +1 -0
  90. package/types/polygon.d.ts +8 -0
  91. package/types/polygon.js +1 -0
  92. package/types/select.d.ts +25 -0
  93. package/types/select.js +1 -0
  94. package/types/vue-template-point.d.ts +54 -0
  95. package/{types.js → types/vue-template-point.js} +0 -3
  96. package/utils/ProjectionUtils.d.ts +28 -0
  97. package/utils/ProjectionUtils.js +34 -0
  98. package/utils/ValidationUtils.d.ts +33 -86
  99. package/utils/ValidationUtils.js +60 -165
  100. package/core/DomPoint.d.ts +0 -21
  101. package/core/DomPoint.js +0 -36
  102. package/core/Line.d.ts +0 -49
  103. package/core/Line.js +0 -114
  104. package/core/Polygon.js +0 -646
  105. package/docs/.vitepress/cache/deps/@theme_index.js +0 -275
  106. package/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
  107. package/docs/.vitepress/cache/deps/_metadata.json +0 -40
  108. package/docs/.vitepress/cache/deps/chunk-LW4I4DCF.js +0 -12542
  109. package/docs/.vitepress/cache/deps/chunk-LW4I4DCF.js.map +0 -7
  110. package/docs/.vitepress/cache/deps/chunk-Z5QSWKN2.js +0 -9719
  111. package/docs/.vitepress/cache/deps/chunk-Z5QSWKN2.js.map +0 -7
  112. package/docs/.vitepress/cache/deps/package.json +0 -3
  113. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4505
  114. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
  115. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -583
  116. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
  117. package/docs/.vitepress/cache/deps/vue.js +0 -343
  118. package/docs/.vitepress/cache/deps/vue.js.map +0 -7
  119. package/types.d.ts +0 -372
package/docs/Line.md CHANGED
@@ -1,187 +1,215 @@
1
- # Line 线要素类
2
-
3
- `Line` 类用于在地图上绘制线要素,支持 GeoJSON 数据加载、自定义样式和图层管理。
4
-
5
- ## 构造函数
6
-
7
- ```typescript
8
- const line = new Line(map: Map);
9
- ```
10
-
11
- - **map**: OpenLayers 地图实例。
12
-
13
- ## 接口定义
14
-
15
- ### LineOptions
16
-
17
- 配置线图层的样式、属性和行为。继承自 `BaseOptions`, `StyleOptions`, `TextOptions`。
18
-
19
- | 属性 | 类型 | 说明 |
20
- | :--- | :--- | :--- |
21
- | **基础配置** | | |
22
- | `layerName` | `string` | 图层名称,用于唯一标识和管理图层 |
23
- | `zIndex` | `number` | 图层层级,默认自动处理 |
24
- | `visible` | `boolean` | 图层是否可见,默认 `true` |
25
- | `opacity` | `number` | 图层透明度 (0-1) |
26
- | `fitView` | `boolean` | 添加要素后是否自动缩放视图以适应要素范围 |
27
- | **样式配置** | | |
28
- | `strokeColor` | `string` \| `number[]` | 线条颜色,如 `'#ff0000'` 或 `[255, 0, 0, 1]` |
29
- | `strokeWidth` | `number` | 线条宽度(像素) |
30
- | `lineDash` | `number[]` | 虚线模式,如 `[10, 10]` 表示 10px 实线 10px 间隔 |
31
- | `lineDashOffset` | `number` | 虚线偏移量 |
32
- | `style` | `Style` \| `Function` | 自定义 OpenLayers 样式或样式函数 |
33
- | **文本标注** | | |
34
- | `textVisible` | `boolean` | 是否显示文本标注 |
35
- | `textCallBack` | `(feature) => string` | 获取文本内容的回调函数 |
36
- | `textFont` | `string` | 字体样式,默认 `'12px sans-serif'` |
37
- | `textFillColor` | `string` | 文本填充颜色 |
38
- | `textStrokeColor` | `string` | 文本描边颜色 |
39
- | `textStrokeWidth` | `number` | 文本描边宽度 |
40
- | `textOffsetY` | `number` | 文本 Y 轴偏移量 |
41
- | **其他** | | |
42
- | `type` | `string` | 线条类型标识,会写入 Feature 的属性中 |
43
-
44
- ### MapJSONData (GeoJSON)
45
-
46
- 标准的 GeoJSON 格式数据结构。
47
-
48
- ```typescript
49
- interface MapJSONData {
50
- type: string; // 通常为 "FeatureCollection"
51
- name?: string; // 数据集名称
52
- features: FeatureData[]; // 要素数组
53
- }
54
-
55
- interface FeatureData {
56
- type: string; // "Feature"
57
- properties: any; // 属性对象
58
- geometry: {
59
- type: "LineString" | "MultiLineString";
60
- coordinates: number[][] | number[][][];
61
- };
62
- }
63
- ```
64
-
65
- ## 方法
66
-
67
- ### addLine
68
-
69
- 添加线要素图层。
70
-
71
- ```typescript
72
- addLine(data: MapJSONData, options?: LineOptions): VectorLayer<VectorSource>
73
- ```
74
-
75
- | 参数 | 类型 | 说明 |
76
- | :--- | :--- | :--- |
77
- | `data` | `MapJSONData` | GeoJSON 格式的线数据 |
78
- | `options` | `LineOptions` | 图层配置项 |
79
-
80
- **返回**: 创建的 `VectorLayer` 实例。
81
-
82
- ### addLineByUrl
83
-
84
- URL 加载并添加线要素图层。
85
-
86
- ```typescript
87
- addLineByUrl(url: string, options?: LineOptions): VectorLayer<VectorSource>
88
- ```
89
-
90
- | 参数 | 类型 | 说明 |
91
- | :--- | :--- | :--- |
92
- | `url` | `string` | GeoJSON 数据的 URL 地址 |
93
- | `options` | `LineOptions` | 图层配置项 |
94
-
95
- **返回**: 创建的 `VectorLayer` 实例。
96
-
97
- ### removeLineLayer
98
-
99
- 根据图层名称移除线图层。
100
-
101
- ```typescript
102
- removeLineLayer(layerName: string): void
103
- ```
104
-
105
- | 参数 | 类型 | 说明 |
106
- | :--- | :--- | :--- |
107
- | `layerName` | `string` | 要移除的图层名称 |
108
-
109
- ## 使用示例
110
-
111
- ### 基础用法
112
-
113
- ```typescript
114
- const lineModule = map.getLine();
115
-
116
- // GeoJSON 数据
117
- const lineData = {
118
- type: 'FeatureCollection',
119
- features: [
120
- {
121
- type: 'Feature',
122
- geometry: {
123
- type: 'LineString',
124
- coordinates: [[119.8, 29.9], [119.9, 30.0]]
125
- },
126
- properties: { name: '线路1', status: 'active' }
127
- }
128
- ]
129
- };
130
-
131
- // 添加红色实线
132
- lineModule.addLine(lineData, {
133
- layerName: 'base-line',
134
- strokeColor: '#ff0000',
135
- strokeWidth: 3,
136
- fitView: true
137
- });
138
- ```
139
-
140
- ### 虚线与标注
141
-
142
- ```typescript
143
- lineModule.addLine(lineData, {
144
- layerName: 'dash-line',
145
- strokeColor: '#0000ff',
146
- strokeWidth: 2,
147
- lineDash: [10, 5], // 10px实线,5px间隔
148
- textVisible: true,
149
- textFillColor: '#000',
150
- textStrokeColor: '#fff',
151
- textStrokeWidth: 2,
152
- // 动态获取显示的文本
153
- textCallBack: (feature) => feature.get('name')
154
- });
155
- ```
156
-
157
- ### 自定义样式函数
158
-
159
- ```typescript
160
- import { Style, Stroke } from 'ol/style';
161
-
162
- lineModule.addLine(lineData, {
163
- layerName: 'custom-style-line',
164
- // 根据属性动态设置颜色
165
- style: (feature) => {
166
- const status = feature.get('properties').status;
167
- const color = status === 'active' ? 'green' : 'gray';
168
-
169
- return new Style({
170
- stroke: new Stroke({
171
- color: color,
172
- width: 4
173
- })
174
- });
175
- }
176
- });
177
- ```
178
-
179
- ### 从接口加载
180
-
181
- ```typescript
182
- lineModule.addLineByUrl('/api/lines/all.json', {
183
- layerName: 'api-lines',
184
- strokeColor: 'orange',
185
- strokeWidth: 2
186
- });
187
- ```
1
+ # Line 线要素类
2
+
3
+ `Line` 类用于在地图上管理静态线和流动线,支持 GeoJSON 数据加载、自定义样式、图层管理以及沿线运动符号 / 流光动画。
4
+
5
+ ## 构造函数
6
+
7
+ ```typescript
8
+ const line = new Line(map: Map);
9
+ ```
10
+
11
+ ## 核心类型
12
+
13
+ ### LineOptions
14
+
15
+ 静态线配置,继承自 `BaseOptions`、`StyleOptions`、`TextOptions`。
16
+
17
+ | 属性 | 类型 | 说明 |
18
+ | :--- | :--- | :--- |
19
+ | `layerName` | `string` | 图层名称 |
20
+ | `strokeColor` | `string \| number[]` | 线颜色 |
21
+ | `strokeWidth` | `number` | 线宽 |
22
+ | `lineDash` | `number[]` | 虚线样式 |
23
+ | `lineDashOffset` | `number` | 虚线偏移 |
24
+ | `style` | `Style \| Style[] \| (feature) => Style \| Style[]` | 自定义静态线样式 |
25
+ | `dataProjection` | `string` | 输入数据投影 |
26
+ | `featureProjection` | `string` | 要素投影 |
27
+ | `projectionOptOptions` | `any` | 旧版投影参数,兼容保留 |
28
+
29
+ ### FlowLineOptions
30
+
31
+ 流动线配置,继承 `LineOptions`。
32
+
33
+ | 属性 | 类型 | 说明 |
34
+ | :--- | :--- | :--- |
35
+ | `loop` | `boolean` | 是否循环播放,默认 `true` |
36
+ | `autoStart` | `boolean` | 创建后是否自动开始,默认 `true` |
37
+ | `duration` | `number` | 单轮动画时长,默认 `4000` |
38
+ | `speed` | `number` | 动画速度倍率,小于等于 `0` 时回退为 `1` |
39
+ | `showBaseLine` | `boolean` | 是否显示基础静态线,默认 `true` |
40
+ | `animationMode` | `'icon' \| 'dash' \| 'icon+dash'` | 动画模式 |
41
+ | `flowSymbol` | `{ src?: string; scale?: number; color?: string; rotateWithView?: boolean; count?: number; spacing?: number }` | 沿线运动符号配置 |
42
+
43
+ ### FlowLineLayerHandle
44
+
45
+ ```typescript
46
+ interface FlowLineLayerHandle {
47
+ layer: VectorLayer<VectorSource>
48
+ animationLayer: VectorLayer<VectorSource>
49
+ start: () => void
50
+ pause: () => void
51
+ resume: () => void
52
+ stop: () => void
53
+ setVisible: (visible: boolean) => void
54
+ updateData: (data: MapJSONData) => void
55
+ remove: () => void
56
+ }
57
+ ```
58
+
59
+ - `layer` 始终是基础线图层。
60
+ - `animationLayer` 始终是动画图层。
61
+ - 即使 `showBaseLine: false`,handle 结构也保持完整。
62
+
63
+ ## 公开方法
64
+
65
+ ### addLine
66
+
67
+ ```typescript
68
+ addLine(data: MapJSONData, options?: LineOptions): VectorLayer<VectorSource>
69
+ ```
70
+
71
+ 添加静态线图层。
72
+
73
+ ### addLineByUrl
74
+
75
+ ```typescript
76
+ addLineByUrl(url: string, options?: LineOptions): VectorLayer<VectorSource>
77
+ ```
78
+
79
+ 从 URL 加载并添加静态线图层。
80
+
81
+ ### removeLineLayer
82
+
83
+ ```typescript
84
+ removeLineLayer(layerName: string): void
85
+ ```
86
+
87
+ 移除静态线图层。
88
+
89
+ ## 流动线 / 动态图标线
90
+
91
+ ### addFlowLine
92
+
93
+ ```typescript
94
+ addFlowLine(data: MapJSONData, options?: FlowLineOptions): FlowLineLayerHandle | null
95
+ ```
96
+
97
+ 支持 `LineString` 和 `MultiLineString`。`MultiLineString` 会在内部拆解后参与动画。
98
+ `flowSymbol.src` 不限于箭头,可以是船、车、粒子、标记等任意沿线运动符号;未传时内部会使用默认矢量 moving symbol。
99
+
100
+ ### addFlowLineByUrl
101
+
102
+ ```typescript
103
+ addFlowLineByUrl(url: string, options?: FlowLineOptions): Promise<FlowLineLayerHandle | null>
104
+ ```
105
+
106
+ URL 加载 GeoJSON 后创建流动线。网络失败、JSON 解析失败、数据结构非法时返回 `null`。
107
+
108
+ ### removeFlowLineLayer
109
+
110
+ ```typescript
111
+ removeFlowLineLayer(layerName: string): void
112
+ ```
113
+
114
+ 按图层名移除流动线的基础图层与动画图层。
115
+
116
+ ## 使用示例
117
+
118
+ ### 基础静态线
119
+
120
+ ```typescript
121
+ const lineModule = map.getLine();
122
+
123
+ lineModule.addLine(lineData, {
124
+ layerName: 'base-line',
125
+ strokeColor: '#ff0000',
126
+ strokeWidth: 3
127
+ });
128
+ ```
129
+
130
+ ### 流动线基础用法
131
+
132
+ ```typescript
133
+ const lineModule = map.getLine();
134
+ const flow = lineModule.addFlowLine(lineData, {
135
+ layerName: 'river-flow',
136
+ animationMode: 'icon+dash',
137
+ strokeColor: '#19b1ff',
138
+ strokeWidth: 3,
139
+ lineDash: [18, 12],
140
+ flowSymbol: {
141
+ src: '/symbols/boat.svg',
142
+ scale: 0.9,
143
+ color: '#19b1ff',
144
+ rotateWithView: true,
145
+ count: 2,
146
+ spacing: 0.2
147
+ },
148
+ duration: 3600
149
+ });
150
+ ```
151
+
152
+ ### pause / resume / remove
153
+
154
+ ```typescript
155
+ flow?.pause();
156
+ flow?.resume();
157
+ flow?.stop();
158
+ flow?.remove();
159
+ ```
160
+
161
+ ### updateData
162
+
163
+ ```typescript
164
+ flow?.updateData({
165
+ type: 'FeatureCollection',
166
+ features: [
167
+ {
168
+ type: 'Feature',
169
+ properties: { name: '支流' },
170
+ geometry: {
171
+ type: 'MultiLineString',
172
+ coordinates: [
173
+ [[119.8, 29.9], [119.9, 30.0]],
174
+ [[119.82, 30.02], [119.95, 30.06]]
175
+ ]
176
+ }
177
+ }
178
+ ]
179
+ });
180
+ ```
181
+
182
+ ### 显式投影字段示例
183
+
184
+ ```typescript
185
+ lineModule.addFlowLine(projectedLineData, {
186
+ layerName: 'projected-flow',
187
+ animationMode: 'icon+dash',
188
+ dataProjection: 'EPSG:4490',
189
+ featureProjection: 'EPSG:3857',
190
+ flowSymbol: {
191
+ src: '/symbols/ship.svg',
192
+ scale: 1,
193
+ count: 1,
194
+ spacing: 0.15
195
+ }
196
+ });
197
+ ```
198
+
199
+ 默认输入按经纬度 GeoJSON 处理;如果地图使用其他投影,建议显式传入 `dataProjection` / `featureProjection`。
200
+
201
+ ## 样式兼容说明
202
+
203
+ - `strokeColor`、`strokeWidth`、`lineDash`、`lineDashOffset`、`style` 继续兼容。
204
+ - 当传入 `style` 时,它只控制基础线图层,不直接控制 moving symbol。
205
+ - `animationMode: 'dash'` 未传虚线参数时,内部会补默认虚线样式,确保流光可见。
206
+ - `animationMode: 'icon+dash'` 会同时渲染:
207
+ - 基础线图层
208
+ - 动画虚线图层
209
+ - `postrender` moving symbol 动画
210
+
211
+ ## 与旧版 projectionOptOptions 的关系
212
+
213
+ - 新项目推荐使用 `dataProjection` / `featureProjection`。
214
+ - `projectionOptOptions` 仅用于兼容旧代码,不再作为主入口。
215
+ - 当两者同时存在时,显式字段 `dataProjection` / `featureProjection` 优先级更高。