runbir-tools 1.0.6 → 1.0.8
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 +213 -4
- package/dist/runbir-tools.es.js +8 -4
- package/dist/runbir-tools.umd.js +2 -2
- package/package.json +6 -6
- package/types/components/VueOl.vue.d.ts +2 -2
package/README.md
CHANGED
|
@@ -1,9 +1,218 @@
|
|
|
1
|
-
# 软博工具包
|
|
2
|
-
|
|
3
|
-
这是一个基于vue3开发的工具包
|
|
4
1
|
|
|
2
|
+
# 软博工具包
|
|
3
|
+
这是一个基于vue3开发的工具包,目前包依赖ol和@turf/turf。
|
|
4
|
+
#### 安装包
|
|
5
|
+
```
|
|
6
|
+
npm install runbir-tools
|
|
7
|
+
```
|
|
5
8
|
## 基于ol的快速开发组件
|
|
6
|
-
|
|
9
|
+
主要是基于vue3,对ol的基本功能做双向绑定,以及提供气象相关的一些工具。
|
|
10
|
+
### 快速开始
|
|
11
|
+
基于天地图,创建简单的GIS。
|
|
7
12
|
```typescript
|
|
13
|
+
<script setup>
|
|
14
|
+
import { VueOl } from "runbir-tools";
|
|
15
|
+
import { ref } from "vue";
|
|
16
|
+
const options = ref({
|
|
17
|
+
view: {
|
|
18
|
+
center: [113.41, 23.32],
|
|
19
|
+
zoom: 7,
|
|
20
|
+
projection: "EPSG:4326",
|
|
21
|
+
},
|
|
22
|
+
layers: [
|
|
23
|
+
{
|
|
24
|
+
id: "vec",
|
|
25
|
+
type: "xyz",
|
|
26
|
+
source: {
|
|
27
|
+
url: "https://t{0-7}.tianditu.gov.cn/vec_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}&tk=48fb1019fa26991b5831d6a97db2fc16",
|
|
28
|
+
projection: "EPSG:4326",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "cva",
|
|
33
|
+
type: "xyz",
|
|
34
|
+
source: {
|
|
35
|
+
url: "https://t{0-7}.tianditu.gov.cn/cva_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}&tk=48fb1019fa26991b5831d6a97db2fc16",
|
|
36
|
+
projection: "EPSG:4326",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
</script>
|
|
42
|
+
<template>
|
|
43
|
+
<div class="demo"><vue-ol :options="options"></vue-ol></div>
|
|
44
|
+
</template>
|
|
45
|
+
<style>
|
|
46
|
+
.demo {
|
|
47
|
+
width: 100%;
|
|
48
|
+
height: 100%;
|
|
49
|
+
}
|
|
50
|
+
</style>
|
|
51
|
+
```
|
|
52
|
+
### options配置
|
|
53
|
+
#### 1. options.value.view 视图配置
|
|
54
|
+
视图的options同[ol/view](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html)一致,由于基于vue做了双向绑定,故直接更改属性值即可刷新,免去ol原来的繁琐重渲染操作。
|
|
55
|
+
例如,更改视图中心点
|
|
56
|
+
```
|
|
57
|
+
options.value.view.center = [newlng,newlat]
|
|
58
|
+
```
|
|
8
59
|
|
|
60
|
+
#### 2. options.value.layers 图层配置
|
|
61
|
+
图层配置目前仅支持以下图层
|
|
62
|
+
##### 2.1 xyz配置
|
|
63
|
+
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是图层的唯一标记,示例如下:
|
|
64
|
+
```typescript
|
|
65
|
+
<script setup>
|
|
66
|
+
import { VueOl } from "runbir-tools";
|
|
67
|
+
import { ref } from "vue";
|
|
68
|
+
const options = ref({
|
|
69
|
+
view: {.....},
|
|
70
|
+
layers: [
|
|
71
|
+
{
|
|
72
|
+
id: "radar",
|
|
73
|
+
type: "xyz",
|
|
74
|
+
source: {
|
|
75
|
+
url: "https://xxxx/data/radar_cut/20250703093600/{z}/{x}/{y}.png",
|
|
76
|
+
projection: "EPSG:4326",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
</script>
|
|
82
|
+
```
|
|
83
|
+
更改图层配置项值,同样能够直接渲染到地图
|
|
84
|
+
```
|
|
85
|
+
const radar = options.value.layers.find((l: any) => l.id === 'radar')
|
|
86
|
+
radar.source.url = "新的url"
|
|
9
87
|
```
|
|
88
|
+
删除图片则直接在layers删除即可
|
|
89
|
+
```
|
|
90
|
+
const index = options.value.layers.findIndex((l: any) => l.id === 'radar')
|
|
91
|
+
options.value.layers.splice(index, 1)
|
|
92
|
+
```
|
|
93
|
+
##### 2.2 imageStatic 静态图片配置
|
|
94
|
+
imageStatic的options同[ol/layer/image](https://openlayers.org/en/latest/apidoc/module-ol_layer_Image-ImageLayer.html)和
|
|
95
|
+
[ol/source/ImageStatic](https://openlayers.org/en/latest/apidoc/module-ol_source_ImageStatic-Static.html)一致,必须配置type:"imageStatic"以及id(自定义命名),id是图层的唯一标记,示例如下:
|
|
96
|
+
```typescript
|
|
97
|
+
<script setup>
|
|
98
|
+
import { VueOl } from "runbir-tools";
|
|
99
|
+
import { ref } from "vue";
|
|
100
|
+
const options = ref({
|
|
101
|
+
view: {.....},
|
|
102
|
+
layers: [
|
|
103
|
+
{
|
|
104
|
+
id: 'satellite',
|
|
105
|
+
type: 'imageStatic',
|
|
106
|
+
opacity: 0.2,
|
|
107
|
+
source: {
|
|
108
|
+
imageExtent: [54.3, -5, 159.6, 66],
|
|
109
|
+
url: 'https://xxxx/data/cloud/3D/20250704/FY2G_2025_07_04_02_01_M_PJ1_3D.GIF',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
</script>
|
|
115
|
+
```
|
|
116
|
+
更新和删除同上
|
|
117
|
+
##### 2.3 point 散点配置
|
|
118
|
+
point的options同[ol/layer/Vector](https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html)和
|
|
119
|
+
[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是图层的唯一标记;示例如下:
|
|
120
|
+
```typescript
|
|
121
|
+
<script setup>
|
|
122
|
+
import { VueOl } from "runbir-tools";
|
|
123
|
+
import { ref } from "vue";
|
|
124
|
+
const options = ref({
|
|
125
|
+
view: {.....},
|
|
126
|
+
layers: [
|
|
127
|
+
{
|
|
128
|
+
id: 'point',
|
|
129
|
+
type: 'point',
|
|
130
|
+
data: [
|
|
131
|
+
{
|
|
132
|
+
lng: 113.5,
|
|
133
|
+
lat: 23.5,
|
|
134
|
+
style: {
|
|
135
|
+
image: {
|
|
136
|
+
type: 'circle',
|
|
137
|
+
radius: 10,
|
|
138
|
+
fill: { color: 'blue' },
|
|
139
|
+
stroke: { color: 'white', width: 2 },
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{ lng: 113.6, lat: 23.6, value: 22 },
|
|
144
|
+
{
|
|
145
|
+
lng: 113.4,
|
|
146
|
+
lat: 23.6,
|
|
147
|
+
winds: 14,
|
|
148
|
+
windd: 342,
|
|
149
|
+
style: { image: { type: 'windBarb' } },
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
lng: 113.5,
|
|
153
|
+
lat: 25.5,
|
|
154
|
+
text: '22mm',
|
|
155
|
+
style: { text: { font: '14px sans-serif' } },
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
});
|
|
161
|
+
</script>
|
|
162
|
+
```
|
|
163
|
+
更新删除同上
|
|
164
|
+
##### 2.3 typhoon 台风配置
|
|
165
|
+
台风配置必须配置type:"typhoon以及id(自定义命名),id是图层的唯一标记,data数据格式只可以参考以下链接;示例如下:
|
|
166
|
+
```typescript
|
|
167
|
+
const typhoon = {
|
|
168
|
+
"tsId": "764",
|
|
169
|
+
"tscName": "罗莎",
|
|
170
|
+
"tseName": "krosa",
|
|
171
|
+
"intlId": "2509",
|
|
172
|
+
"intId": "",
|
|
173
|
+
"landOn": "",
|
|
174
|
+
"origin": "",
|
|
175
|
+
"meanings": "",
|
|
176
|
+
"remark": "",
|
|
177
|
+
"crtTime": "2025-08-03 15:54:22.0"
|
|
178
|
+
}
|
|
179
|
+
const typhoonPath = (await getTyphoonPath('https://www.gzqxfw.com.cn/data/typhoon/2025/764.json')) as any
|
|
180
|
+
const data: any = { baseInfo: typhoon }
|
|
181
|
+
data.mainPath = 'BABJ' // 如果配置这项,则为单个台风单条路径(多用于面向公众系统);如果没有配置,则是单个台风多条路径(多用于内部系统)
|
|
182
|
+
typhoonPath.BABJ.color = '#ff0000'
|
|
183
|
+
typhoonPath.BCGZ.color = '#ff00ff'
|
|
184
|
+
typhoonPath.PGTW.color = '#91f4f5'
|
|
185
|
+
typhoonPath.RJTD.color = '#6eba39'
|
|
186
|
+
typhoonPath.VHHH.color = '#e39538'
|
|
187
|
+
data.data = typhoonPath
|
|
188
|
+
const ty = { id: 'typhoon', type: 'typhoon', data }
|
|
189
|
+
options.value.layers.push(ty)
|
|
190
|
+
```
|
|
191
|
+
台风不提供更新、修改路径的功能(业务上很少有这种操作);删除同上
|
|
192
|
+
#### 3. options.value.event 事件配置
|
|
193
|
+
关于ol的事件,建议使用以下配置;由于包内部也应用了事件监听,为了节约系统开支,使用以下配置统一调度
|
|
194
|
+
```typescript
|
|
195
|
+
const options = ref<any>({
|
|
196
|
+
view: {....... },
|
|
197
|
+
layers: [.....],
|
|
198
|
+
event: {
|
|
199
|
+
register: ['singleclick'],
|
|
200
|
+
callback: (event: any) => {
|
|
201
|
+
console.log(event)
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
})
|
|
205
|
+
```
|
|
206
|
+
#### 4. 以上功能不满足的情况下,可以获取地图对象,进行自定义操作
|
|
207
|
+
|
|
208
|
+
目前该组件只封装了一些常见的功能,在功能不满足使用的情况下,请获取地图对象,用原生ol编写代码;获取地图对象方法如下:
|
|
209
|
+
```typescript
|
|
210
|
+
<script setup lang="ts">
|
|
211
|
+
const getMapObject = (map: any) => {
|
|
212
|
+
console.log(map)
|
|
213
|
+
}
|
|
214
|
+
</script>
|
|
215
|
+
<template>
|
|
216
|
+
<vue-ol :options="mapOptions" @ol-map="getMapObject" />
|
|
217
|
+
</template>
|
|
218
|
+
```
|
package/dist/runbir-tools.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".map[data-v-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".map[data-v-d0235b39]{width:100%;height:100%}@keyframes rotate-d0235b39{0%{transform:rotate(0)}to{transform:rotate(360deg)}}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
2
|
var ze = Object.defineProperty;
|
|
3
3
|
var Ve = (s, e, t) => e in s ? ze(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
4
4
|
var se = (s, e, t) => Ve(s, typeof e != "symbol" ? e + "" : e, t);
|
|
@@ -24375,8 +24375,12 @@ const _hoisted_1 = {
|
|
|
24375
24375
|
const t = new VectorLayer({
|
|
24376
24376
|
...e,
|
|
24377
24377
|
source: getPointSource(s)
|
|
24378
|
-
})
|
|
24379
|
-
|
|
24378
|
+
});
|
|
24379
|
+
if (s.style) {
|
|
24380
|
+
const i = typeof s.style == "function" ? s.style : getStyle(s.style);
|
|
24381
|
+
t.setStyle(i);
|
|
24382
|
+
}
|
|
24383
|
+
return t;
|
|
24380
24384
|
}, getTypeoonLayer = (s) => {
|
|
24381
24385
|
const e = [], t = [];
|
|
24382
24386
|
if (s.data.mainPath) {
|
|
@@ -24618,7 +24622,7 @@ const _hoisted_1 = {
|
|
|
24618
24622
|
for (const [i, n] of e)
|
|
24619
24623
|
t[i] = n;
|
|
24620
24624
|
return t;
|
|
24621
|
-
}, VueOl = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
24625
|
+
}, VueOl = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d0235b39"]]), plugin = {
|
|
24622
24626
|
install(s) {
|
|
24623
24627
|
s.component("VueOl", VueOl);
|
|
24624
24628
|
}
|