@zhangdali1996/lr-map-viewer 0.0.13 → 0.0.15

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
@@ -298,14 +298,6 @@ createApp(App).use(LrMapViewerPlugin).mount('#app')
298
298
  - `get3dInstance()`
299
299
  - `resize()`
300
300
  - `refreshScene()`
301
- - `saveView()`
302
- - `restoreView(viewState)`
303
- - `initializeDemoPerson()`
304
- - `startDemoPersonMotion(x, y, z)`
305
- - `stopDemoPersonMotion()`
306
- - `toggleDemoPersonMotion(x, y, z)`
307
- - `focusDemoPerson()`
308
- - `moveView(x, y, z)`
309
301
  - `registerModelInfoQuery(callback)`
310
302
 
311
303
  说明:
@@ -313,12 +305,93 @@ createApp(App).use(LrMapViewerPlugin).mount('#app')
313
305
  - `switchMode(mode)` 支持在 `2d / 3d` 间切换当前显示引擎。
314
306
  - `get2dInstance()` 返回当前二维 adapter 实例,其中包含 `map`、`options`、`behavior`、`layerTree` 等信息。
315
307
  - `refreshScene()` 仅对三维场景有效。
316
- - `saveView()` 用于保存当前三维视角快照,返回结果可直接交给 `restoreView(viewState)` 复原。
317
- - `initializeDemoPerson()`、`startDemoPersonMotion()`、`stopDemoPersonMotion()`、`toggleDemoPersonMotion()`、`focusDemoPerson()` 仅对三维场景有效,用于控制示例人员对象。
318
- - `moveView(x, y, z)` 传入的是绝对三维坐标,组件内部会自动换算成相对 `basePoint` 坐标后调用聚焦接口。
319
308
  - `registerModelInfoQuery(callback)` 会在用户点击三维中的模型对象时触发回调。
320
309
  - 模型信息查询返回 4 个字段:`id`、`name`、`layerName`、`position`。
321
310
 
311
+ ## 监测点模块
312
+
313
+ 监测点相关能力通过组件实例提供,适合业务侧自己实现外部按钮、列表和联动逻辑。
314
+
315
+ 监测点模块 expose:
316
+
317
+ - `initMonitorPoints()`
318
+ - `queryMonitorPointList()`
319
+ - `reloadMonitorPoints()`
320
+ - `focusMonitorPoint(target)`
321
+ - `focusPerson(target)`
322
+ - `movePerson(target)`
323
+
324
+ 说明:
325
+
326
+ - `initMonitorPoints()` 用于初始化监测点,组件会查询监测点数据并加载显示到三维场景中。
327
+ - `queryMonitorPointList()` 会重新查询最新监测点数据,并返回列表结果,但不会把结果重新加载到地图上。
328
+ - `reloadMonitorPoints()` 会先清空当前场景中已加载的监测点,再重新查询并加载,避免重复添加。
329
+ - `focusMonitorPoint(target)` 会将视口移动到指定监测点,并打开该监测点的信息弹窗;`target` 支持传监测点 `id` 或监测点对象。
330
+ - `focusPerson(target)` 用于聚焦指定人员定位对象;`target` 支持传人员 `sceneId`、人员名称或人员对象,不传时默认聚焦第一名人员。
331
+ - `movePerson(target)` 用于触发指定人员的轨迹移动;`target` 的传参规则与 `focusPerson(target)` 保持一致。
332
+
333
+ ## 视角控制模块
334
+
335
+ 视角控制相关能力同样通过组件实例提供,便于业务侧自己实现“视角列表 + 当前视口保存恢复”。
336
+
337
+ 视角控制模块 expose:
338
+
339
+ - `getViewPointList()`
340
+ - `switchToViewPoint(target)`
341
+ - `getCurrentViewInfo()`
342
+ - `applyViewInfo(viewInfo)`
343
+
344
+ 说明:
345
+
346
+ - `getViewPointList()` 返回当前预设视角列表,列表项包含 `key`、`name`、`cameraPos`、`viewCenter`。
347
+ - `switchToViewPoint(target)` 用于切换到指定预设视角;`target` 支持传预设视角 `key`、视角名称或视角对象。
348
+ - `getCurrentViewInfo()` 用于读取当前视口的视角信息,返回结果可直接作为 `applyViewInfo(viewInfo)` 的入参。
349
+ - `applyViewInfo(viewInfo)` 用于按传入的视角参数恢复视口位置和视角中心。
350
+
351
+ ## 其他 3D 方法
352
+
353
+ 以下方法继续保留,主要用于兼容现有接入方式或演示人员联动:
354
+
355
+ - `initializeDemoPerson()`
356
+ - `startDemoPersonMotion(x, y, z)`
357
+ - `stopDemoPersonMotion()`
358
+ - `toggleDemoPersonMotion(x, y, z)`
359
+ - `focusDemoPerson()`
360
+ - `moveView(x, y, z)`
361
+
362
+ 说明:
363
+
364
+ - `initializeDemoPerson()` 用于初始化人员演示对象或人员轨迹对象。
365
+ - `startDemoPersonMotion()`、`stopDemoPersonMotion()`、`toggleDemoPersonMotion()` 为旧的人员演示控制方法。
366
+ - `focusDemoPerson()` 用于聚焦当前主人员对象。
367
+ - `moveView(x, y, z)` 用于按绝对坐标快速聚焦目标点。
368
+
369
+ ## 范围选点模块
370
+
371
+ 范围选点相关能力单独通过组件实例提供,适合外部业务系统自己实现按钮、面板和联动逻辑,而不是依赖组件内部调试面板。
372
+
373
+ 范围选点模块 expose:
374
+
375
+ - `startRangeSelection(options)`
376
+ - `cancelRangeSelection(options)`
377
+ - `setRangeSelection(center, options)`
378
+ - `setRangeSelectionRadius(radius)`
379
+ - `clearRangeSelection()`
380
+ - `getRangeSelectionResult()`
381
+ - `registerRangeSelectionChange(callback)`
382
+ - `focusMonitorPoint(target)`
383
+
384
+ 说明:
385
+
386
+ - `startRangeSelection(options)` 用于启动范围选点,支持通过 `options.radius` 指定初始半径。
387
+ - `cancelRangeSelection(options)` 用于取消当前范围选点,可通过 `options.preserveCurrentResult` 控制是否保留当前结果。
388
+ - `setRangeSelection(center, options)` 用于直接传入三维坐标生成球形范围,适合业务系统通过外部坐标直接驱动范围选点。
389
+ - `setRangeSelectionRadius(radius)` 用于更新当前范围半径;如果当前已完成选点,会同步更新球体和范围内测点。
390
+ - `clearRangeSelection()` 用于清除当前范围球、选点标记和测点过滤结果。
391
+ - `getRangeSelectionResult()` 返回当前范围选点结果,包含状态、半径、球心坐标、当前巷道信息和范围内测点列表。
392
+ - `registerRangeSelectionChange(callback)` 会在开始选点、选点完成、半径变化、取消、清除时触发回调。
393
+ - `focusMonitorPoint(target)` 用于定位并打开指定测点的信息窗,支持传测点 `id` 或测点对象。
394
+
322
395
  ## 二维图纸配置说明
323
396
 
324
397
  推荐写法:
@@ -388,6 +461,93 @@ const map2dConfig = {
388
461
 
389
462
  推荐通过 `ref` 调用组件实例方法:
390
463
 
464
+ ### 监测点模块示例
465
+
466
+ ```vue
467
+ <script setup>
468
+ import { ref } from 'vue'
469
+ import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
470
+
471
+ const viewerRef = ref(null)
472
+
473
+ async function handleInitMonitorPoints() {
474
+ await viewerRef.value?.initMonitorPoints?.()
475
+ }
476
+
477
+ async function handleReloadMonitorPoints() {
478
+ await viewerRef.value?.reloadMonitorPoints?.()
479
+ }
480
+
481
+ async function handleQueryMonitorPoints() {
482
+ const list = await viewerRef.value?.queryMonitorPointList?.()
483
+ console.log('monitor points', list)
484
+ }
485
+
486
+ function handleFocusMonitorPoint() {
487
+ viewerRef.value?.focusMonitorPoint?.('mock-monitor-point-1')
488
+ }
489
+
490
+ function handleFocusPerson() {
491
+ viewerRef.value?.focusPerson?.()
492
+ }
493
+
494
+ function handleMovePerson() {
495
+ viewerRef.value?.movePerson?.()
496
+ }
497
+ </script>
498
+
499
+ <template>
500
+ <div style="height: 100vh;">
501
+ <button type="button" @click="handleInitMonitorPoints">初始化监测点</button>
502
+ <button type="button" @click="handleReloadMonitorPoints">重新加载监测点</button>
503
+ <button type="button" @click="handleQueryMonitorPoints">查询监测点</button>
504
+ <button type="button" @click="handleFocusMonitorPoint">聚焦监测点</button>
505
+ <button type="button" @click="handleFocusPerson">聚焦人员</button>
506
+ <button type="button" @click="handleMovePerson">人员移动</button>
507
+ <LrMapViewer ref="viewerRef" :lr3d-config="lr3dConfig" />
508
+ </div>
509
+ </template>
510
+ ```
511
+
512
+ ### 视角控制模块示例
513
+
514
+ ```vue
515
+ <script setup>
516
+ import { ref } from 'vue'
517
+ import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
518
+
519
+ const viewerRef = ref(null)
520
+ const currentViewInfo = ref(null)
521
+
522
+ function handleSwitchViewPoint() {
523
+ viewerRef.value?.switchToViewPoint?.('井口')
524
+ }
525
+
526
+ function handleCaptureViewInfo() {
527
+ currentViewInfo.value = viewerRef.value?.getCurrentViewInfo?.() ?? null
528
+ }
529
+
530
+ function handleRestoreViewInfo() {
531
+ if (currentViewInfo.value) {
532
+ viewerRef.value?.applyViewInfo?.(currentViewInfo.value)
533
+ }
534
+ }
535
+ </script>
536
+
537
+ <template>
538
+ <div style="height: 100vh;">
539
+ <button type="button" @click="handleSwitchViewPoint">切换到井口视角</button>
540
+ <button type="button" @click="handleCaptureViewInfo">读取当前视口</button>
541
+ <button type="button" @click="handleRestoreViewInfo">按视角参数恢复</button>
542
+ <LrMapViewer ref="viewerRef" :lr3d-config="lr3dConfig" />
543
+ </div>
544
+ </template>
545
+ ```
546
+
547
+ ### 范围选点模块示例
548
+
549
+ 如果你需要通过组件实例控制范围选点:
550
+
391
551
  ```vue
392
552
  <script setup>
393
553
  import { ref, watch } from 'vue'
@@ -395,27 +555,34 @@ import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
395
555
 
396
556
  const viewerRef = ref(null)
397
557
 
398
- function handleMoveView() {
399
- viewerRef.value?.moveView?.(
400
- // x 坐标(绝对坐标)
401
- 37515326.469929,
402
- // y 坐标(绝对坐标)
403
- 4412734.214238,
404
- // z 坐标(绝对坐标)
405
- 1311.15,
406
- )
558
+ function startRangeSelection() {
559
+ viewerRef.value?.startRangeSelection?.({
560
+ radius: 500,
561
+ })
562
+ }
563
+
564
+ function clearRangeSelection() {
565
+ viewerRef.value?.clearRangeSelection?.()
566
+ }
567
+
568
+ function focusFirstMonitorPoint() {
569
+ const result = viewerRef.value?.getRangeSelectionResult?.()
570
+ const firstMonitorPoint = result?.monitorPoints?.[0]
571
+
572
+ if (firstMonitorPoint) {
573
+ viewerRef.value?.focusMonitorPoint?.(firstMonitorPoint)
574
+ }
407
575
  }
408
576
 
409
577
  watch(
410
578
  viewerRef,
411
579
  (viewer) => {
412
- if (!viewer?.registerModelInfoQuery) {
580
+ if (!viewer?.registerRangeSelectionChange) {
413
581
  return
414
582
  }
415
583
 
416
- viewer.registerModelInfoQuery((payload) => {
417
- // payload 为点击模型后返回的模型信息
418
- console.log('model info', payload)
584
+ viewer.registerRangeSelectionChange((payload) => {
585
+ console.log('range selection', payload)
419
586
  })
420
587
  },
421
588
  { immediate: true },
@@ -424,7 +591,9 @@ watch(
424
591
 
425
592
  <template>
426
593
  <div style="height: 100vh;">
427
- <button type="button" @click="handleMoveView">移动视角</button>
594
+ <button type="button" @click="startRangeSelection">开始范围选点</button>
595
+ <button type="button" @click="clearRangeSelection">清除范围</button>
596
+ <button type="button" @click="focusFirstMonitorPoint">定位首个测点</button>
428
597
  <LrMapViewer ref="viewerRef" :lr3d-config="lr3dConfig" />
429
598
  </div>
430
599
  </template>