runbir-tools 1.0.15 → 1.0.17
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 +65 -26
- package/dist/runbir-tools.es.js +180 -142
- package/dist/runbir-tools.umd.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
2
1
|
# 软博工具包
|
|
2
|
+
|
|
3
3
|
这是一个基于vue3开发的工具包,目前包依赖ol和@turf/turf。
|
|
4
|
+
|
|
4
5
|
#### 安装包
|
|
6
|
+
|
|
5
7
|
```
|
|
6
8
|
npm install runbir-tools
|
|
7
9
|
```
|
|
10
|
+
|
|
8
11
|
## 基于ol的快速开发组件
|
|
12
|
+
|
|
9
13
|
主要是基于vue3,对ol的基本功能做双向绑定,以及提供气象相关的一些工具。
|
|
14
|
+
|
|
10
15
|
### 快速开始
|
|
16
|
+
|
|
11
17
|
基于天地图,创建简单的GIS。
|
|
18
|
+
|
|
12
19
|
```typescript
|
|
13
20
|
<script setup>
|
|
14
21
|
import { VueOl } from "runbir-tools";
|
|
@@ -49,18 +56,26 @@ const options = ref({
|
|
|
49
56
|
}
|
|
50
57
|
</style>
|
|
51
58
|
```
|
|
59
|
+
|
|
52
60
|
### options配置
|
|
61
|
+
|
|
53
62
|
#### 1. options.value.view 视图配置
|
|
63
|
+
|
|
54
64
|
视图的options同[ol/view](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html)一致,由于基于vue做了双向绑定,故直接更改属性值即可刷新,免去ol原来的繁琐重渲染操作。
|
|
55
65
|
例如,更改视图中心点
|
|
66
|
+
|
|
56
67
|
```
|
|
57
68
|
options.value.view.center = [newlng,newlat]
|
|
58
69
|
```
|
|
59
70
|
|
|
60
71
|
#### 2. options.value.layers 图层配置
|
|
72
|
+
|
|
61
73
|
图层配置目前仅支持以下图层
|
|
62
|
-
|
|
74
|
+
|
|
75
|
+
##### 2.1 xyz配置
|
|
76
|
+
|
|
63
77
|
xyz的options同[ol/layer/Tile](https://openlayers.org/en/latest/apidoc/module-ol_layer_Tile-TileLayer.html)和[ol/source/xyz](https://openlayers.org/en/latest/apidoc/module-ol_source_XYZ-XYZ.html)一致,必须配置type:"xyz"以及id(自定义命名),id是图层的唯一标记,示例如下:
|
|
78
|
+
|
|
64
79
|
```typescript
|
|
65
80
|
<script setup>
|
|
66
81
|
import { VueOl } from "runbir-tools";
|
|
@@ -71,6 +86,7 @@ const options = ref({
|
|
|
71
86
|
{
|
|
72
87
|
id: "radar",
|
|
73
88
|
type: "xyz",
|
|
89
|
+
useInterimTilesWhenMissing: true, // 当为true时,错误瓦片用空白图代替
|
|
74
90
|
source: {
|
|
75
91
|
url: "https://xxxx/data/radar_cut/20250703093600/{z}/{x}/{y}.png",
|
|
76
92
|
projection: "EPSG:4326",
|
|
@@ -80,19 +96,26 @@ const options = ref({
|
|
|
80
96
|
});
|
|
81
97
|
</script>
|
|
82
98
|
```
|
|
99
|
+
|
|
83
100
|
更改图层配置项值,同样能够直接渲染到地图
|
|
101
|
+
|
|
84
102
|
```
|
|
85
103
|
const radar = options.value.layers.find((l: any) => l.id === 'radar')
|
|
86
104
|
radar.source.url = "新的url"
|
|
87
105
|
```
|
|
106
|
+
|
|
88
107
|
删除图片则直接在layers删除即可
|
|
108
|
+
|
|
89
109
|
```
|
|
90
110
|
const index = options.value.layers.findIndex((l: any) => l.id === 'radar')
|
|
91
111
|
options.value.layers.splice(index, 1)
|
|
92
112
|
```
|
|
113
|
+
|
|
93
114
|
##### 2.2 imageStatic 静态图片配置
|
|
115
|
+
|
|
94
116
|
imageStatic的options同[ol/layer/image](https://openlayers.org/en/latest/apidoc/module-ol_layer_Image-ImageLayer.html)和
|
|
95
117
|
[ol/source/ImageStatic](https://openlayers.org/en/latest/apidoc/module-ol_source_ImageStatic-Static.html)一致,必须配置type:"imageStatic"以及id(自定义命名),id是图层的唯一标记,示例如下:
|
|
118
|
+
|
|
96
119
|
```typescript
|
|
97
120
|
<script setup>
|
|
98
121
|
import { VueOl } from "runbir-tools";
|
|
@@ -113,10 +136,14 @@ const options = ref({
|
|
|
113
136
|
});
|
|
114
137
|
</script>
|
|
115
138
|
```
|
|
139
|
+
|
|
116
140
|
更新和删除同上
|
|
141
|
+
|
|
117
142
|
##### 2.3 point 散点配置
|
|
143
|
+
|
|
118
144
|
point的options同[ol/layer/Vector](https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html)和
|
|
119
145
|
[ol/source/Vector](https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html)一致(仅支持ol/geom/Point,style样式除了ol内置style,还额外提供一个小组件风向杆),必须配置type:"point以及id(自定义命名),id是图层的唯一标记;示例如下:
|
|
146
|
+
|
|
120
147
|
```typescript
|
|
121
148
|
<script setup>
|
|
122
149
|
import { VueOl } from "runbir-tools";
|
|
@@ -160,37 +187,47 @@ const options = ref({
|
|
|
160
187
|
});
|
|
161
188
|
</script>
|
|
162
189
|
```
|
|
190
|
+
|
|
163
191
|
更新删除同上
|
|
192
|
+
|
|
164
193
|
##### 2.3 typhoon 台风配置
|
|
194
|
+
|
|
165
195
|
台风配置必须配置type:"typhoon以及id(自定义命名),id是图层的唯一标记,data数据格式只可以参考以下链接;示例如下:
|
|
196
|
+
|
|
166
197
|
```typescript
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
198
|
+
const typhoon = {
|
|
199
|
+
tsId: '764',
|
|
200
|
+
tscName: '罗莎',
|
|
201
|
+
tseName: 'krosa',
|
|
202
|
+
intlId: '2509',
|
|
203
|
+
intId: '',
|
|
204
|
+
landOn: '',
|
|
205
|
+
origin: '',
|
|
206
|
+
meanings: '',
|
|
207
|
+
remark: '',
|
|
208
|
+
crtTime: '2025-08-03 15:54:22.0',
|
|
209
|
+
}
|
|
210
|
+
const typhoonPath = (await getTyphoonPath(
|
|
211
|
+
'https://www.gzqxfw.com.cn/data/typhoon/2025/764.json',
|
|
212
|
+
)) as any
|
|
213
|
+
const data: any = { baseInfo: typhoon }
|
|
214
|
+
data.mainPath = 'BABJ' // 如果配置这项,则为单个台风单条路径(多用于面向公众系统);如果没有配置,则是单个台风多条路径(多用于内部系统)
|
|
215
|
+
typhoonPath.BABJ.color = '#ff0000'
|
|
216
|
+
typhoonPath.BCGZ.color = '#ff00ff'
|
|
217
|
+
typhoonPath.PGTW.color = '#91f4f5'
|
|
218
|
+
typhoonPath.RJTD.color = '#6eba39'
|
|
219
|
+
typhoonPath.VHHH.color = '#e39538'
|
|
220
|
+
data.data = typhoonPath
|
|
221
|
+
const ty = { id: 'typhoon', type: 'typhoon', data }
|
|
222
|
+
options.value.layers.push(ty)
|
|
190
223
|
```
|
|
224
|
+
|
|
191
225
|
台风不提供更新、修改路径的功能(业务上很少有这种操作);删除同上
|
|
226
|
+
|
|
192
227
|
#### 3. options.value.event 事件配置
|
|
228
|
+
|
|
193
229
|
关于ol的事件,建议使用以下配置;由于包内部也应用了事件监听,为了节约系统开支,使用以下配置统一调度
|
|
230
|
+
|
|
194
231
|
```typescript
|
|
195
232
|
const options = ref<any>({
|
|
196
233
|
view: {....... },
|
|
@@ -203,9 +240,11 @@ const options = ref<any>({
|
|
|
203
240
|
},
|
|
204
241
|
})
|
|
205
242
|
```
|
|
243
|
+
|
|
206
244
|
#### 4. 以上功能不满足的情况下,可以获取地图对象,进行自定义操作
|
|
207
245
|
|
|
208
246
|
目前该组件只封装了一些常见的功能,在功能不满足使用的情况下,请获取地图对象,用原生ol编写代码;获取地图对象方法如下:
|
|
247
|
+
|
|
209
248
|
```typescript
|
|
210
249
|
<script setup lang="ts">
|
|
211
250
|
const getMapObject = (map: any) => {
|
|
@@ -215,4 +254,4 @@ const options = ref<any>({
|
|
|
215
254
|
<template>
|
|
216
255
|
<vue-ol :options="mapOptions" @ol-map="getMapObject" />
|
|
217
256
|
</template>
|
|
218
|
-
```
|
|
257
|
+
```
|