@zhangdali1996/lr-map-viewer 0.0.5 → 0.0.7
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 +187 -11
- package/dist/lr-map-viewer.css +1 -1
- package/dist/lr-map-viewer.js +1359 -1080
- 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,20 +50,18 @@ 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'
|
|
53
58
|
|
|
59
|
+
const credentialKey = 'your_credential_key'
|
|
60
|
+
|
|
54
61
|
const lr3dConfig = {
|
|
55
62
|
// 是否在场景初始化成功后自动加载云 GIS 数据
|
|
56
63
|
autoLoad: true,
|
|
57
64
|
cloud: {
|
|
58
|
-
// 云 GIS 服务地址
|
|
59
|
-
server: 'https://your-cloud-gis-server/',
|
|
60
|
-
// 云 GIS 用户名
|
|
61
|
-
username: 'your_username',
|
|
62
|
-
// 云 GIS 密码
|
|
63
|
-
password: 'your_password',
|
|
64
65
|
// 数据源 guid
|
|
65
66
|
dsGuid: 'your_ds_guid',
|
|
66
67
|
// 三维场景基点
|
|
@@ -83,7 +84,85 @@ const lr3dConfig = {
|
|
|
83
84
|
|
|
84
85
|
<template>
|
|
85
86
|
<div style="height: 100vh;">
|
|
86
|
-
<LrMapViewer :lr3d-config="lr3dConfig" />
|
|
87
|
+
<LrMapViewer :lr3d-config="lr3dConfig" :credential-key="credentialKey" />
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 二维图纸示例
|
|
93
|
+
|
|
94
|
+
```vue
|
|
95
|
+
<script setup>
|
|
96
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
97
|
+
|
|
98
|
+
const credentialKey = 'your_credential_key'
|
|
99
|
+
|
|
100
|
+
const map2dConfig = {
|
|
101
|
+
behavior: {
|
|
102
|
+
autoInitLayer: true,
|
|
103
|
+
autoShowLayer: true,
|
|
104
|
+
captureLayerTree: true,
|
|
105
|
+
},
|
|
106
|
+
options: {
|
|
107
|
+
ygis_dsGuid: 'your_ds_guid',
|
|
108
|
+
layerName: 'your_layer_name',
|
|
109
|
+
layerCode: '',
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<template>
|
|
115
|
+
<div style="height: 100vh;">
|
|
116
|
+
<LrMapViewer
|
|
117
|
+
mode="2d"
|
|
118
|
+
:modes="['2d']"
|
|
119
|
+
:map2d-config="map2dConfig"
|
|
120
|
+
:credential-key="credentialKey"
|
|
121
|
+
/>
|
|
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 credentialKey = 'your_credential_key'
|
|
135
|
+
|
|
136
|
+
const map2dConfig = {
|
|
137
|
+
options: {
|
|
138
|
+
ygis_dsGuid: 'your_ds_guid',
|
|
139
|
+
layerName: 'your_layer_name',
|
|
140
|
+
},
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const lr3dConfig = {
|
|
144
|
+
autoLoad: true,
|
|
145
|
+
cloud: {
|
|
146
|
+
dsGuid: 'your_ds_guid',
|
|
147
|
+
basePoint: {
|
|
148
|
+
x: 37517614.46684,
|
|
149
|
+
y: 4410289.679932,
|
|
150
|
+
z: 972.148557,
|
|
151
|
+
},
|
|
152
|
+
layers: ['your_lane_layer_name'],
|
|
153
|
+
},
|
|
154
|
+
}
|
|
155
|
+
</script>
|
|
156
|
+
|
|
157
|
+
<template>
|
|
158
|
+
<div style="height: 100vh;">
|
|
159
|
+
<LrMapViewer
|
|
160
|
+
:mode="activeMode"
|
|
161
|
+
:modes="['2d', '3d']"
|
|
162
|
+
:map2d-config="map2dConfig"
|
|
163
|
+
:lr3d-config="lr3dConfig"
|
|
164
|
+
:credential-key="credentialKey"
|
|
165
|
+
/>
|
|
87
166
|
</div>
|
|
88
167
|
</template>
|
|
89
168
|
```
|
|
@@ -93,6 +172,7 @@ const lr3dConfig = {
|
|
|
93
172
|
```vue
|
|
94
173
|
<LrMapViewer
|
|
95
174
|
:lr3d-config="lr3dConfig"
|
|
175
|
+
:credential-key="credentialKey"
|
|
96
176
|
:show-region-panel="true"
|
|
97
177
|
:show-debug-panel="true"
|
|
98
178
|
/>
|
|
@@ -126,8 +206,16 @@ createApp(App).use(LrMapViewerPlugin).mount('#app')
|
|
|
126
206
|
|
|
127
207
|
组件 Props:
|
|
128
208
|
|
|
209
|
+
- `mode`
|
|
210
|
+
当前激活模式,支持 `2d` 或 `3d`。
|
|
211
|
+
- `modes`
|
|
212
|
+
当前组件允许启用的模式列表,默认 `['3d']`。
|
|
213
|
+
- `map2dConfig`
|
|
214
|
+
二维图纸运行时配置。
|
|
129
215
|
- `lr3dConfig`
|
|
130
216
|
龙软三维运行时配置。
|
|
217
|
+
- `credentialKey`
|
|
218
|
+
内部凭证解密 Key,二维与三维都会使用它解析内置认证信息。
|
|
131
219
|
- `showRegionPanel`
|
|
132
220
|
是否显示区域显隐面板,默认 `false`。
|
|
133
221
|
- `showDebugPanel`
|
|
@@ -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
|
|