@zhangdali1996/lr-map-viewer 0.0.4 → 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 CHANGED
@@ -4,9 +4,13 @@
4
4
 
5
5
  主要能力:
6
6
 
7
+ - 支持 Vue 3 项目中以组件方式挂载二维图纸容器。
7
8
  - 支持 Vue 3 项目中以组件方式挂载三维地图容器。
9
+ - 支持 `2d / 3d` 模式切换与统一壳层承载。
8
10
  - 支持龙软三维 SDK 的运行时加载。
11
+ - 支持通过运行时配置传入二维图纸参数。
9
12
  - 支持通过运行时配置传入云 GIS 参数。
13
+ - 支持通过运行时配置显式传入三维场景 `basePoint`。
10
14
  - 支持按需显示区域显隐面板和调试面板。
11
15
  - 支持通过组件实例调用 `moveView(x, y, z)` 移动三维视角。
12
16
  - 支持通过组件实例注册 `registerModelInfoQuery(callback)` 查询点击模型信息。
@@ -46,6 +50,8 @@ public/
46
50
 
47
51
  ## 最小接入示例
48
52
 
53
+ ### 三维示例
54
+
49
55
  ```vue
50
56
  <script setup>
51
57
  import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
@@ -56,16 +62,18 @@ const lr3dConfig = {
56
62
  cloud: {
57
63
  // 云 GIS 服务地址
58
64
  server: 'https://your-cloud-gis-server/',
59
- // 地图服务地址
60
- mapServerUrl: 'https://your-map-server/',
61
65
  // 云 GIS 用户名
62
66
  username: 'your_username',
63
67
  // 云 GIS 密码
64
68
  password: 'your_password',
65
69
  // 数据源 guid
66
70
  dsGuid: 'your_ds_guid',
67
- // 数据源名称
68
- dsname: 'your_ds_name',
71
+ // 三维场景基点
72
+ basePoint: {
73
+ x: 37517614.46684,
74
+ y: 4410289.679932,
75
+ z: 972.148557,
76
+ },
69
77
  // 需要加载的巷道图层名
70
78
  layers: ['your_lane_layer_name'],
71
79
  laneSize: {
@@ -74,15 +82,6 @@ const lr3dConfig = {
74
82
  // 巷道渲染高度
75
83
  height: 10,
76
84
  },
77
- // 需要加载的煤层图层名数组
78
- coalLayers: ['your_coal_layer_name'],
79
- // 需要加载的断层图层名数组
80
- geofaultLayers: [],
81
- // 以下开关和要素编码均提供默认值,按需覆盖即可
82
- workfaceFeatureTypes: ['0202030030'],
83
- regionFeatureTypes: ['0202030030', '0106020009', '0202030004', '0202030006'],
84
- enableRegionAssist: false,
85
- enableLane: true,
86
85
  },
87
86
  }
88
87
  </script>
@@ -94,6 +93,83 @@ const lr3dConfig = {
94
93
  </template>
95
94
  ```
96
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
+
97
173
  如果你需要默认显示右上角区域显隐面板和调试面板:
98
174
 
99
175
  ```vue
@@ -132,6 +208,12 @@ createApp(App).use(LrMapViewerPlugin).mount('#app')
132
208
 
133
209
  组件 Props:
134
210
 
211
+ - `mode`
212
+ 当前激活模式,支持 `2d` 或 `3d`。
213
+ - `modes`
214
+ 当前组件允许启用的模式列表,默认 `['3d']`。
215
+ - `map2dConfig`
216
+ 二维图纸运行时配置。
135
217
  - `lr3dConfig`
136
218
  龙软三维运行时配置。
137
219
  - `showRegionPanel`
@@ -144,6 +226,7 @@ createApp(App).use(LrMapViewerPlugin).mount('#app')
144
226
  - `switchMode(mode)`
145
227
  - `getCurrentMode()`
146
228
  - `getCurrentEngine()`
229
+ - `get2dInstance()`
147
230
  - `get3dInstance()`
148
231
  - `resize()`
149
232
  - `refreshScene()`
@@ -152,11 +235,70 @@ createApp(App).use(LrMapViewerPlugin).mount('#app')
152
235
 
153
236
  说明:
154
237
 
238
+ - `switchMode(mode)` 支持在 `2d / 3d` 间切换当前显示引擎。
239
+ - `get2dInstance()` 返回当前二维 adapter 实例,其中包含 `map`、`options`、`behavior`、`layerTree` 等信息。
155
240
  - `refreshScene()` 仅对三维场景有效。
156
241
  - `moveView(x, y, z)` 传入的是绝对三维坐标,组件内部会自动换算成相对 `basePoint` 坐标后调用聚焦接口。
157
242
  - `registerModelInfoQuery(callback)` 会在用户点击三维中的模型对象时触发回调。
158
243
  - 模型信息查询返回 4 个字段:`id`、`name`、`layerName`、`position`。
159
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
+
160
302
  ## 接口示例
161
303
 
162
304
  推荐通过 `ref` 调用组件实例方法:
@@ -203,6 +345,38 @@ watch(
203
345
  </template>
204
346
  ```
205
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
+
206
380
  模型信息查询回调返回结构:
207
381
 
208
382
  ```js
@@ -233,18 +407,19 @@ const lr3dConfig = {
233
407
  autoLoad: true,
234
408
  cloud: {
235
409
  server: 'https://your-cloud-gis-server/',
236
- mapServerUrl: 'https://your-map-server/',
237
410
  username: 'your_username',
238
411
  password: 'your_password',
239
412
  dsGuid: 'your_ds_guid',
240
- dsname: 'your_ds_name',
413
+ basePoint: {
414
+ x: 37517614.46684,
415
+ y: 4410289.679932,
416
+ z: 972.148557,
417
+ },
241
418
  layers: ['your_lane_layer_name'],
242
419
  laneSize: {
243
420
  width: 10,
244
421
  height: 10,
245
422
  },
246
- coalLayers: ['your_coal_layer_name'],
247
- geofaultLayers: [],
248
423
  },
249
424
  }
250
425
  ```
@@ -255,16 +430,18 @@ const lr3dConfig = {
255
430
  是否在场景初始化成功后自动加载云 GIS 数据。
256
431
  - `cloud.server`
257
432
  云 GIS 服务地址。
258
- - `cloud.mapServerUrl`
259
- 地图服务地址。
260
433
  - `cloud.username`
261
434
  云 GIS 用户名。
262
435
  - `cloud.password`
263
436
  云 GIS 密码。
264
437
  - `cloud.dsGuid`
265
438
  数据源 guid。
266
- - `cloud.dsname`
267
- 数据源名称。
439
+ - `cloud.basePoint.x`
440
+ 三维场景基点 x 坐标。
441
+ - `cloud.basePoint.y`
442
+ 三维场景基点 y 坐标。
443
+ - `cloud.basePoint.z`
444
+ 三维场景基点 z 坐标。
268
445
 
269
446
  可选字段:
270
447
 
@@ -274,22 +451,11 @@ const lr3dConfig = {
274
451
  巷道渲染宽度,默认 `10`
275
452
  - `cloud.laneSize.height`
276
453
  巷道渲染高度,默认 `10`
277
- - `cloud.coalLayers`
278
- 需要加载的煤层图层名数组。
279
- - `cloud.geofaultLayers`
280
- 需要加载的断层图层名数组。
281
- - `cloud.workfaceFeatureTypes`
282
- 工作面要素编码数组,不传时使用默认值。
283
- - `cloud.regionFeatureTypes`
284
- 区域要素编码数组,不传时使用默认值。
285
- - `cloud.enableRegionAssist`
286
- 是否启用掘进辅助数据,默认 `false`。
287
- - `cloud.enableLane`
288
- 是否启用巷道加载,默认 `true`。
289
454
 
290
455
  兼容说明:
291
456
 
292
457
  - 组件内部仍兼容完整的 `lr3dConfig` 写法。
458
+ - `basePoint` 推荐传入 `{ x, y, z }` 对象。
293
459
  - 如果你需要覆盖 SDK 路径、容器参数、初始化参数等高级配置,仍然可以继续传入 `sdk`、`scene`、`initOptions`、`dataSource` 完整结构。
294
460
 
295
461
  ## 示例配置
@@ -301,22 +467,19 @@ const playgroundLr3dConfig = {
301
467
  autoLoad: true,
302
468
  cloud: {
303
469
  server: 'https://your-cloud-gis-server/',
304
- mapServerUrl: 'https://your-map-server/',
305
470
  username: 'your_username',
306
471
  password: 'your_password',
307
472
  dsGuid: 'your_ds_guid',
308
- dsname: 'your_ds_name',
473
+ basePoint: {
474
+ x: 37517614.46684,
475
+ y: 4410289.679932,
476
+ z: 972.148557,
477
+ },
309
478
  layers: ['your_lane_layer_name'],
310
479
  laneSize: {
311
480
  width: 10,
312
481
  height: 10,
313
482
  },
314
- coalLayers: ['your_coal_layer_name'],
315
- geofaultLayers: [],
316
- workfaceFeatureTypes: ['0202030030'],
317
- regionFeatureTypes: ['0202030030', '0106020009', '0202030004', '0202030006'],
318
- enableRegionAssist: false,
319
- enableLane: true,
320
483
  },
321
484
  }
322
485
  ```
@@ -353,8 +516,8 @@ const playgroundLr3dConfig = {
353
516
  典型原因:
354
517
 
355
518
  - 组件库默认配置已不再携带真实业务参数。
356
- - 接入方没有传入 `server`、`mapServerUrl`、`username`、`password`、`dsGuid`、`dsname`。
519
+ - 接入方没有传入 `server`、`username`、`password`、`dsGuid`、`basePoint`。
357
520
 
358
521
  处理方式:
359
522
 
360
- - 在 `lr3dConfig.cloud` 中补齐实际项目所需字段。
523
+ - 在 `lr3dConfig.cloud` 中补齐实际项目所需字段。