@zhangdali1996/lr-map-viewer 0.0.5 → 0.0.6
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 +180 -4
- package/dist/lr-map-viewer.js +20 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
主要能力:
|
|
6
6
|
|
|
7
|
+
- 支持 Vue 3 项目中以组件方式挂载二维图纸容器。
|
|
7
8
|
- 支持 Vue 3 项目中以组件方式挂载三维地图容器。
|
|
9
|
+
- 支持 `2d / 3d` 模式切换与统一壳层承载。
|
|
8
10
|
- 支持龙软三维 SDK 的运行时加载。
|
|
11
|
+
- 支持通过运行时配置传入二维图纸参数。
|
|
9
12
|
- 支持通过运行时配置传入云 GIS 参数。
|
|
10
13
|
- 支持通过运行时配置显式传入三维场景 `basePoint`。
|
|
11
14
|
- 支持按需显示区域显隐面板和调试面板。
|
|
@@ -47,6 +50,8 @@ public/
|
|
|
47
50
|
|
|
48
51
|
## 最小接入示例
|
|
49
52
|
|
|
53
|
+
### 三维示例
|
|
54
|
+
|
|
50
55
|
```vue
|
|
51
56
|
<script setup>
|
|
52
57
|
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
@@ -88,6 +93,83 @@ const lr3dConfig = {
|
|
|
88
93
|
</template>
|
|
89
94
|
```
|
|
90
95
|
|
|
96
|
+
### 二维图纸示例
|
|
97
|
+
|
|
98
|
+
```vue
|
|
99
|
+
<script setup>
|
|
100
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
101
|
+
|
|
102
|
+
const map2dConfig = {
|
|
103
|
+
behavior: {
|
|
104
|
+
autoInitLayer: true,
|
|
105
|
+
autoShowLayer: true,
|
|
106
|
+
captureLayerTree: true,
|
|
107
|
+
},
|
|
108
|
+
options: {
|
|
109
|
+
ygis_dsGuid: 'your_ds_guid',
|
|
110
|
+
ygis_url: 'https://your-cloud-gis-server/',
|
|
111
|
+
Url: 'https://your-map-server/',
|
|
112
|
+
layerName: 'your_layer_name',
|
|
113
|
+
layerCode: '',
|
|
114
|
+
token: 'your_token',
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<template>
|
|
120
|
+
<div style="height: 100vh;">
|
|
121
|
+
<LrMapViewer mode="2d" :modes="['2d']" :map2d-config="map2dConfig" />
|
|
122
|
+
</div>
|
|
123
|
+
</template>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 二维三维切换示例
|
|
127
|
+
|
|
128
|
+
```vue
|
|
129
|
+
<script setup>
|
|
130
|
+
import { ref } from 'vue'
|
|
131
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
132
|
+
|
|
133
|
+
const activeMode = ref('2d')
|
|
134
|
+
const map2dConfig = {
|
|
135
|
+
options: {
|
|
136
|
+
ygis_dsGuid: 'your_ds_guid',
|
|
137
|
+
ygis_url: 'https://your-cloud-gis-server/',
|
|
138
|
+
Url: 'https://your-map-server/',
|
|
139
|
+
layerName: 'your_layer_name',
|
|
140
|
+
token: 'your_token',
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const lr3dConfig = {
|
|
145
|
+
autoLoad: true,
|
|
146
|
+
cloud: {
|
|
147
|
+
server: 'https://your-cloud-gis-server/',
|
|
148
|
+
username: 'your_username',
|
|
149
|
+
password: 'your_password',
|
|
150
|
+
dsGuid: 'your_ds_guid',
|
|
151
|
+
basePoint: {
|
|
152
|
+
x: 37517614.46684,
|
|
153
|
+
y: 4410289.679932,
|
|
154
|
+
z: 972.148557,
|
|
155
|
+
},
|
|
156
|
+
layers: ['your_lane_layer_name'],
|
|
157
|
+
},
|
|
158
|
+
}
|
|
159
|
+
</script>
|
|
160
|
+
|
|
161
|
+
<template>
|
|
162
|
+
<div style="height: 100vh;">
|
|
163
|
+
<LrMapViewer
|
|
164
|
+
:mode="activeMode"
|
|
165
|
+
:modes="['2d', '3d']"
|
|
166
|
+
:map2d-config="map2dConfig"
|
|
167
|
+
:lr3d-config="lr3dConfig"
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
170
|
+
</template>
|
|
171
|
+
```
|
|
172
|
+
|
|
91
173
|
如果你需要默认显示右上角区域显隐面板和调试面板:
|
|
92
174
|
|
|
93
175
|
```vue
|
|
@@ -126,6 +208,12 @@ createApp(App).use(LrMapViewerPlugin).mount('#app')
|
|
|
126
208
|
|
|
127
209
|
组件 Props:
|
|
128
210
|
|
|
211
|
+
- `mode`
|
|
212
|
+
当前激活模式,支持 `2d` 或 `3d`。
|
|
213
|
+
- `modes`
|
|
214
|
+
当前组件允许启用的模式列表,默认 `['3d']`。
|
|
215
|
+
- `map2dConfig`
|
|
216
|
+
二维图纸运行时配置。
|
|
129
217
|
- `lr3dConfig`
|
|
130
218
|
龙软三维运行时配置。
|
|
131
219
|
- `showRegionPanel`
|
|
@@ -138,6 +226,7 @@ createApp(App).use(LrMapViewerPlugin).mount('#app')
|
|
|
138
226
|
- `switchMode(mode)`
|
|
139
227
|
- `getCurrentMode()`
|
|
140
228
|
- `getCurrentEngine()`
|
|
229
|
+
- `get2dInstance()`
|
|
141
230
|
- `get3dInstance()`
|
|
142
231
|
- `resize()`
|
|
143
232
|
- `refreshScene()`
|
|
@@ -146,11 +235,70 @@ createApp(App).use(LrMapViewerPlugin).mount('#app')
|
|
|
146
235
|
|
|
147
236
|
说明:
|
|
148
237
|
|
|
238
|
+
- `switchMode(mode)` 支持在 `2d / 3d` 间切换当前显示引擎。
|
|
239
|
+
- `get2dInstance()` 返回当前二维 adapter 实例,其中包含 `map`、`options`、`behavior`、`layerTree` 等信息。
|
|
149
240
|
- `refreshScene()` 仅对三维场景有效。
|
|
150
241
|
- `moveView(x, y, z)` 传入的是绝对三维坐标,组件内部会自动换算成相对 `basePoint` 坐标后调用聚焦接口。
|
|
151
242
|
- `registerModelInfoQuery(callback)` 会在用户点击三维中的模型对象时触发回调。
|
|
152
243
|
- 模型信息查询返回 4 个字段:`id`、`name`、`layerName`、`position`。
|
|
153
244
|
|
|
245
|
+
## 二维图纸配置说明
|
|
246
|
+
|
|
247
|
+
推荐写法:
|
|
248
|
+
|
|
249
|
+
```js
|
|
250
|
+
const map2dConfig = {
|
|
251
|
+
behavior: {
|
|
252
|
+
autoInitLayer: true,
|
|
253
|
+
autoShowLayer: true,
|
|
254
|
+
captureLayerTree: true,
|
|
255
|
+
},
|
|
256
|
+
options: {
|
|
257
|
+
ygis_dsGuid: 'your_ds_guid',
|
|
258
|
+
ygis_url: 'https://your-cloud-gis-server/',
|
|
259
|
+
Url: 'https://your-map-server/',
|
|
260
|
+
layerName: 'your_layer_name',
|
|
261
|
+
layerCode: '',
|
|
262
|
+
token: 'your_token',
|
|
263
|
+
extent: '',
|
|
264
|
+
rotate: false,
|
|
265
|
+
animate: false,
|
|
266
|
+
zoomAnimation: false,
|
|
267
|
+
markerZoomAnimation: false,
|
|
268
|
+
fadeAnimation: false,
|
|
269
|
+
},
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
必填字段:
|
|
274
|
+
|
|
275
|
+
- `map2dConfig.options.ygis_dsGuid`
|
|
276
|
+
二维图纸数据源 guid。
|
|
277
|
+
- `map2dConfig.options.ygis_url`
|
|
278
|
+
云 GIS 服务地址。
|
|
279
|
+
- `map2dConfig.options.Url`
|
|
280
|
+
二维地图服务地址。
|
|
281
|
+
- `map2dConfig.options.token`
|
|
282
|
+
二维认证 token,和用户名密码二选一。
|
|
283
|
+
|
|
284
|
+
认证兼容说明:
|
|
285
|
+
|
|
286
|
+
- 如果没有 `token`,则需要同时传入 `map2dConfig.options.ygis_username` 和 `map2dConfig.options.ygis_password`。
|
|
287
|
+
- 当 `map2dConfig.behavior.autoShowLayer` 为 `true` 时,`map2dConfig.options.layerName` 也属于必填项。
|
|
288
|
+
|
|
289
|
+
常用可选字段:
|
|
290
|
+
|
|
291
|
+
- `map2dConfig.options.layerCode`
|
|
292
|
+
图层编码,默认可传空字符串。
|
|
293
|
+
- `map2dConfig.options.extent`
|
|
294
|
+
初始范围。
|
|
295
|
+
- `map2dConfig.behavior.autoInitLayer`
|
|
296
|
+
是否自动初始化图层,默认 `true`。
|
|
297
|
+
- `map2dConfig.behavior.autoShowLayer`
|
|
298
|
+
是否自动显示指定图层,默认 `true`。
|
|
299
|
+
- `map2dConfig.behavior.captureLayerTree`
|
|
300
|
+
是否抓取图层树,默认 `true`。
|
|
301
|
+
|
|
154
302
|
## 接口示例
|
|
155
303
|
|
|
156
304
|
推荐通过 `ref` 调用组件实例方法:
|
|
@@ -197,6 +345,38 @@ watch(
|
|
|
197
345
|
</template>
|
|
198
346
|
```
|
|
199
347
|
|
|
348
|
+
如果你需要切换二维与三维模式:
|
|
349
|
+
|
|
350
|
+
```vue
|
|
351
|
+
<script setup>
|
|
352
|
+
import { ref } from 'vue'
|
|
353
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
354
|
+
|
|
355
|
+
const viewerRef = ref(null)
|
|
356
|
+
|
|
357
|
+
function switchTo2d() {
|
|
358
|
+
viewerRef.value?.switchMode?.('2d')
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function switchTo3d() {
|
|
362
|
+
viewerRef.value?.switchMode?.('3d')
|
|
363
|
+
}
|
|
364
|
+
</script>
|
|
365
|
+
|
|
366
|
+
<template>
|
|
367
|
+
<div style="height: 100vh;">
|
|
368
|
+
<button type="button" @click="switchTo2d">查看二维</button>
|
|
369
|
+
<button type="button" @click="switchTo3d">查看三维</button>
|
|
370
|
+
<LrMapViewer
|
|
371
|
+
ref="viewerRef"
|
|
372
|
+
:modes="['2d', '3d']"
|
|
373
|
+
:map2d-config="map2dConfig"
|
|
374
|
+
:lr3d-config="lr3dConfig"
|
|
375
|
+
/>
|
|
376
|
+
</div>
|
|
377
|
+
</template>
|
|
378
|
+
```
|
|
379
|
+
|
|
200
380
|
模型信息查询回调返回结构:
|
|
201
381
|
|
|
202
382
|
```js
|
|
@@ -271,10 +451,6 @@ const lr3dConfig = {
|
|
|
271
451
|
巷道渲染宽度,默认 `10`
|
|
272
452
|
- `cloud.laneSize.height`
|
|
273
453
|
巷道渲染高度,默认 `10`
|
|
274
|
-
- `cloud.mapServerUrl`
|
|
275
|
-
可按业务需要继续透传,但不再用于组件内部计算 `basePoint`。
|
|
276
|
-
- `cloud.dsname`
|
|
277
|
-
可按业务需要继续透传,但不再作为三维基础加载必填项。
|
|
278
454
|
|
|
279
455
|
兼容说明:
|
|
280
456
|
|
package/dist/lr-map-viewer.js
CHANGED
|
@@ -207,11 +207,9 @@ var he = {
|
|
|
207
207
|
loadMode: "workfaceOnly",
|
|
208
208
|
cloud: {
|
|
209
209
|
server: "",
|
|
210
|
-
mapServerUrl: "",
|
|
211
210
|
username: "",
|
|
212
211
|
password: "",
|
|
213
212
|
dsGuid: "",
|
|
214
|
-
dsname: "",
|
|
215
213
|
basePoint: null,
|
|
216
214
|
layers: [],
|
|
217
215
|
demoPerson: {
|
|
@@ -231,7 +229,6 @@ var he = {
|
|
|
231
229
|
"0202030004",
|
|
232
230
|
"0202030006"
|
|
233
231
|
],
|
|
234
|
-
enableRegionAssist: !1,
|
|
235
232
|
enableLane: !0
|
|
236
233
|
}
|
|
237
234
|
}
|
|
@@ -2661,13 +2658,12 @@ function Ba(e) {
|
|
|
2661
2658
|
};
|
|
2662
2659
|
}
|
|
2663
2660
|
function Va(e = {}) {
|
|
2664
|
-
let t = Se(), n = e.loadMode ?? t?.loadMode ?? "all", r = e.
|
|
2661
|
+
let t = Se(), n = e.loadMode ?? t?.loadMode ?? "all", r = e.regionFeatureTypes ?? t?.cloud?.regionFeatureTypes ?? _a, i = e.enableLane ?? t?.cloud?.enableLane ?? !1, a = {
|
|
2665
2662
|
...t?.cloud ?? {},
|
|
2666
2663
|
...e,
|
|
2667
2664
|
loadMode: n,
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
enableLane: a
|
|
2665
|
+
regionFeatureTypes: r,
|
|
2666
|
+
enableLane: i
|
|
2671
2667
|
};
|
|
2672
2668
|
if ([
|
|
2673
2669
|
"server",
|
|
@@ -2675,27 +2671,26 @@ function Va(e = {}) {
|
|
|
2675
2671
|
"password",
|
|
2676
2672
|
"dsGuid"
|
|
2677
2673
|
].forEach((e) => {
|
|
2678
|
-
let t =
|
|
2674
|
+
let t = a[e];
|
|
2679
2675
|
if (typeof t != "string" || !t.trim()) throw Error(`云 GIS 数据源配置缺失: ${e}`);
|
|
2680
|
-
}), !Array.isArray(
|
|
2681
|
-
if (!Array.isArray(
|
|
2682
|
-
if (!Array.isArray(
|
|
2683
|
-
if (!Array.isArray(
|
|
2684
|
-
if (!Array.isArray(
|
|
2685
|
-
let
|
|
2686
|
-
if (n === "workfaceOnly" &&
|
|
2676
|
+
}), !Array.isArray(a.coalLayers)) throw Error("云 GIS 数据源配置错误: coalLayers 必须为数组");
|
|
2677
|
+
if (!Array.isArray(a.workfaceFeatureTypes)) throw Error("云 GIS 数据源配置错误: workfaceFeatureTypes 必须为数组");
|
|
2678
|
+
if (!Array.isArray(a.regionFeatureTypes)) throw Error("云 GIS 数据源配置错误: regionFeatureTypes 必须为数组");
|
|
2679
|
+
if (!Array.isArray(a.layers ?? [])) throw Error("云 GIS 数据源配置错误: layers 必须为数组");
|
|
2680
|
+
if (!Array.isArray(a.geofaultLayers ?? [])) throw Error("云 GIS 数据源配置错误: geofaultLayers 必须为数组");
|
|
2681
|
+
let o = a.workfaceFeatureTypes.map((e) => typeof e == "string" ? e.trim() : "").filter(Boolean), s = a.regionFeatureTypes.map((e) => typeof e == "string" ? e.trim() : "").filter(Boolean);
|
|
2682
|
+
if (n === "workfaceOnly" && o.length === 0) throw Error("工作面加载模式下,workfaceFeatureTypes 至少需要一个要素编码");
|
|
2687
2683
|
return {
|
|
2688
|
-
...
|
|
2684
|
+
...a,
|
|
2689
2685
|
loadMode: n,
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
workfaceFeatureTypes: s
|
|
2686
|
+
enableLane: !!a.enableLane,
|
|
2687
|
+
basePoint: za(a.basePoint),
|
|
2688
|
+
laneSize: Ba(a),
|
|
2689
|
+
coalLayers: a.coalLayers.map((e) => typeof e == "string" ? e.trim() : "").filter(Boolean),
|
|
2690
|
+
layers: (a.layers ?? []).map((e) => typeof e == "string" ? e.trim() : "").filter(Boolean),
|
|
2691
|
+
geofaultLayers: (a.geofaultLayers ?? []).map((e) => typeof e == "string" ? e.trim() : "").filter(Boolean),
|
|
2692
|
+
regionFeatureTypes: s.length > 0 ? s : [..._a],
|
|
2693
|
+
workfaceFeatureTypes: o
|
|
2699
2694
|
};
|
|
2700
2695
|
}
|
|
2701
2696
|
function Ha(e) {
|