@zhangdali1996/lr-map-viewer 0.0.15 → 0.0.17
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 +795 -785
- package/dist/lr-map-viewer.css +1 -1
- package/dist/lr-map-viewer.js +8468 -7492
- package/package.json +34 -33
package/README.md
CHANGED
|
@@ -1,785 +1,795 @@
|
|
|
1
|
-
# @zhangdali1996/lr-map-viewer
|
|
2
|
-
|
|
3
|
-
`@zhangdali1996/lr-map-viewer` 是面向 Vue 3 项目的三维地图组件库,提供龙软三维场景承载能力,以及基于组件实例的视角控制与模型信息查询能力。
|
|
4
|
-
|
|
5
|
-
主要能力:
|
|
6
|
-
|
|
7
|
-
- 支持 Vue 3 项目中以组件方式挂载二维图纸容器。
|
|
8
|
-
- 支持 Vue 3 项目中以组件方式挂载三维地图容器。
|
|
9
|
-
- 支持 `2d / 3d` 模式切换与统一壳层承载。
|
|
10
|
-
- 支持龙软三维 SDK 的运行时加载。
|
|
11
|
-
- 支持通过运行时配置传入二维图纸参数。
|
|
12
|
-
- 支持通过运行时配置传入云 GIS 参数。
|
|
13
|
-
- 支持通过运行时配置显式传入三维场景 `basePoint`。
|
|
14
|
-
- 支持按需显示区域显隐面板、调试面板和监测点面板。
|
|
15
|
-
- 支持通过组件实例调用 `moveView(x, y, z)` 移动三维视角。
|
|
16
|
-
- 支持通过组件实例保存/恢复视角,以及控制演示人员的初始化、运动和聚焦。
|
|
17
|
-
- 支持通过组件实例注册 `registerModelInfoQuery(callback)` 查询点击模型信息。
|
|
18
|
-
|
|
19
|
-
## 安装
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install @zhangdali1996/lr-map-viewer
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
`vue` 和 `element-plus` 作为 `peerDependencies` 提供,要求使用方项目自行安装。
|
|
26
|
-
|
|
27
|
-
二维图纸依赖的 `@longruan/lr-map` 已随当前组件库构建产物内置,客户项目安装本包时不需要再额外访问公司内网 npm 拉取这个依赖。
|
|
28
|
-
|
|
29
|
-
安装后请显式引入组件库样式:
|
|
30
|
-
|
|
31
|
-
```js
|
|
32
|
-
import '@zhangdali1996/lr-map-viewer/style.css'
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
说明:
|
|
36
|
-
|
|
37
|
-
- 这部分样式对应组件库自身的布局、面板、占位态等 UI。
|
|
38
|
-
- 龙软 SDK 的 `/editorapp`、`/resource` 静态资源及其中的样式,仍需由实施方单独提供。
|
|
39
|
-
|
|
40
|
-
## 静态资源放置
|
|
41
|
-
|
|
42
|
-
该包不会携带龙软 SDK 的大体积静态资源。以下目录需要由实施方单独提供给客户:
|
|
43
|
-
|
|
44
|
-
- `editorapp`
|
|
45
|
-
- `resource`
|
|
46
|
-
|
|
47
|
-
推荐放置到客户项目的 `public` 目录:
|
|
48
|
-
|
|
49
|
-
```text
|
|
50
|
-
public/
|
|
51
|
-
editorapp/
|
|
52
|
-
resource/
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
对应默认访问路径:
|
|
56
|
-
|
|
57
|
-
- `/editorapp/editorapp.bundle.js`
|
|
58
|
-
- `/resource/js/three.min.js`
|
|
59
|
-
- `/resource/js/vue.2.6.11.js`
|
|
60
|
-
- `/resource/js/element_ui.js`
|
|
61
|
-
- `/resource/js/jquery-3.1.1.min.js`
|
|
62
|
-
|
|
63
|
-
如果客户项目的静态资源目录不是根路径,需要通过 `lr3dConfig.sdk` 自定义覆盖路径。
|
|
64
|
-
|
|
65
|
-
如果客户项目把龙软静态资源统一挂在某个业务前缀下,也可以只传 `sdk.resourcePrefix`,让组件自动给默认的 `/editorapp` 和 `/resource` 路径补前缀。
|
|
66
|
-
|
|
67
|
-
例如:
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
const lr3dConfig = {
|
|
71
|
-
sdk: {
|
|
72
|
-
resourcePrefix: 'gkpt',
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
会自动解析为:
|
|
78
|
-
|
|
79
|
-
- `/gkpt/editorapp/editorapp.bundle.js`
|
|
80
|
-
- `/gkpt/resource/js/three.min.js`
|
|
81
|
-
- `/gkpt/resource/js/vue.2.6.11.js`
|
|
82
|
-
- `/gkpt/resource/js/element_ui.js`
|
|
83
|
-
- `/gkpt/resource/js/jquery-3.1.1.min.js`
|
|
84
|
-
|
|
85
|
-
说明:
|
|
86
|
-
|
|
87
|
-
- 不传 `sdk.resourcePrefix` 时,默认仍然使用 `/editorapp` 和 `/resource`
|
|
88
|
-
- 支持传 `gkpt`、`/gkpt`、`gkpt/`、`/gkpt/`,最终都会归一化为 `/gkpt`
|
|
89
|
-
- 如果你已经显式传了完整的 `sdk.scriptSrc` 或 `sdk.dependencies[].src`,则建议直接传最终路径
|
|
90
|
-
|
|
91
|
-
## 最小接入示例
|
|
92
|
-
|
|
93
|
-
### 三维示例
|
|
94
|
-
|
|
95
|
-
```vue
|
|
96
|
-
<script setup>
|
|
97
|
-
import '@zhangdali1996/lr-map-viewer/style.css'
|
|
98
|
-
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
99
|
-
|
|
100
|
-
const credentialKey = 'your_credential_key'
|
|
101
|
-
|
|
102
|
-
const lr3dConfig = {
|
|
103
|
-
// 是否在场景初始化成功后自动加载云 GIS 数据
|
|
104
|
-
autoLoad: true,
|
|
105
|
-
cloud: {
|
|
106
|
-
// 数据源 guid
|
|
107
|
-
dsGuid: 'your_ds_guid',
|
|
108
|
-
// 三维场景基点
|
|
109
|
-
basePoint: {
|
|
110
|
-
x: 37517614.46684,
|
|
111
|
-
y: 4410289.679932,
|
|
112
|
-
z: 972.148557,
|
|
113
|
-
},
|
|
114
|
-
// 需要加载的巷道图层名
|
|
115
|
-
layers: ['your_lane_layer_name'],
|
|
116
|
-
laneSize: {
|
|
117
|
-
// 巷道渲染宽度
|
|
118
|
-
width: 10,
|
|
119
|
-
// 巷道渲染高度
|
|
120
|
-
height: 10,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
}
|
|
124
|
-
</script>
|
|
125
|
-
|
|
126
|
-
<template>
|
|
127
|
-
<div style="height: 100vh;">
|
|
128
|
-
<LrMapViewer :lr3d-config="lr3dConfig" :credential-key="credentialKey" />
|
|
129
|
-
</div>
|
|
130
|
-
</template>
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### 二维图纸示例
|
|
134
|
-
|
|
135
|
-
```vue
|
|
136
|
-
<script setup>
|
|
137
|
-
import '@zhangdali1996/lr-map-viewer/style.css'
|
|
138
|
-
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
139
|
-
|
|
140
|
-
const credentialKey = 'your_credential_key'
|
|
141
|
-
|
|
142
|
-
const map2dConfig = {
|
|
143
|
-
behavior: {
|
|
144
|
-
autoInitLayer: true,
|
|
145
|
-
autoShowLayer: true,
|
|
146
|
-
captureLayerTree: true,
|
|
147
|
-
},
|
|
148
|
-
options: {
|
|
149
|
-
ygis_dsGuid: 'your_ds_guid',
|
|
150
|
-
layerName: 'your_layer_name',
|
|
151
|
-
layerCode: '',
|
|
152
|
-
},
|
|
153
|
-
}
|
|
154
|
-
</script>
|
|
155
|
-
|
|
156
|
-
<template>
|
|
157
|
-
<div style="height: 100vh;">
|
|
158
|
-
<LrMapViewer
|
|
159
|
-
mode="2d"
|
|
160
|
-
:modes="['2d']"
|
|
161
|
-
:map2d-config="map2dConfig"
|
|
162
|
-
:credential-key="credentialKey"
|
|
163
|
-
/>
|
|
164
|
-
</div>
|
|
165
|
-
</template>
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### 二维三维切换示例
|
|
169
|
-
|
|
170
|
-
```vue
|
|
171
|
-
<script setup>
|
|
172
|
-
import { ref } from 'vue'
|
|
173
|
-
import '@zhangdali1996/lr-map-viewer/style.css'
|
|
174
|
-
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
175
|
-
|
|
176
|
-
const activeMode = ref('2d')
|
|
177
|
-
const credentialKey = 'your_credential_key'
|
|
178
|
-
|
|
179
|
-
const map2dConfig = {
|
|
180
|
-
options: {
|
|
181
|
-
ygis_dsGuid: 'your_ds_guid',
|
|
182
|
-
layerName: 'your_layer_name',
|
|
183
|
-
},
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const lr3dConfig = {
|
|
187
|
-
autoLoad: true,
|
|
188
|
-
cloud: {
|
|
189
|
-
dsGuid: 'your_ds_guid',
|
|
190
|
-
basePoint: {
|
|
191
|
-
x: 37517614.46684,
|
|
192
|
-
y: 4410289.679932,
|
|
193
|
-
z: 972.148557,
|
|
194
|
-
},
|
|
195
|
-
layers: ['your_lane_layer_name'],
|
|
196
|
-
},
|
|
197
|
-
}
|
|
198
|
-
</script>
|
|
199
|
-
|
|
200
|
-
<template>
|
|
201
|
-
<div style="height: 100vh;">
|
|
202
|
-
<LrMapViewer
|
|
203
|
-
:mode="activeMode"
|
|
204
|
-
:modes="['2d', '3d']"
|
|
205
|
-
:map2d-config="map2dConfig"
|
|
206
|
-
:lr3d-config="lr3dConfig"
|
|
207
|
-
:credential-key="credentialKey"
|
|
208
|
-
/>
|
|
209
|
-
</div>
|
|
210
|
-
</template>
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
如果你需要默认显示右上角区域显隐面板和调试面板:
|
|
214
|
-
|
|
215
|
-
```vue
|
|
216
|
-
<LrMapViewer
|
|
217
|
-
:lr3d-config="lr3dConfig"
|
|
218
|
-
:credential-key="credentialKey"
|
|
219
|
-
:show-region-panel="true"
|
|
220
|
-
:show-debug-panel="true"
|
|
221
|
-
/>
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
说明:
|
|
225
|
-
|
|
226
|
-
- 三维组件已内置默认的 `sdk`、`scene`、`initOptions`、`dataSource.type`、`dataSource.loadMode` 配置,通常不需要手动传入。
|
|
227
|
-
- 推荐只传 `autoLoad` 和 `cloud` 下的业务参数即可。
|
|
228
|
-
- 如果你有特殊需求,仍然可以继续传完整的 `lr3dConfig` 结构来覆盖默认值。
|
|
229
|
-
|
|
230
|
-
## 推荐接入方式
|
|
231
|
-
|
|
232
|
-
推荐直接按需引入组件:
|
|
233
|
-
|
|
234
|
-
```js
|
|
235
|
-
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
也支持作为插件安装:
|
|
239
|
-
|
|
240
|
-
```js
|
|
241
|
-
import { createApp } from 'vue'
|
|
242
|
-
import LrMapViewerPlugin from '@zhangdali1996/lr-map-viewer'
|
|
243
|
-
import App from './App.vue'
|
|
244
|
-
|
|
245
|
-
createApp(App).use(LrMapViewerPlugin).mount('#app')
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
## 命名导出
|
|
249
|
-
|
|
250
|
-
除默认导出的插件对象外,包入口还提供以下命名导出:
|
|
251
|
-
|
|
252
|
-
- 组件:`LrMapViewer`、`Lr2dViewer`、`Lr3dViewer`
|
|
253
|
-
- 2D 配置工具:`getDefaultLr2dConfig`、`getLr2dConfig`、`getLr2dMapOptions`、`setLr2dConfig`、`resetLr2dConfig`、`resolveLr2dConfig`、`getMissingLr2dOptionFields`、`getRequiredLr2dOptionFields`、`isLr2dConfigReady`
|
|
254
|
-
- 3D 配置工具:`getDefaultLr3dConfig`、`getLr3dConfig`、`setLr3dConfig`、`resetLr3dConfig`、`resolveLr3dConfig`
|
|
255
|
-
- 模式工具:`getSupportedMapModes`、`normalizeMapMode`、`resolveMapModes`、`resolveInitialMapMode`、`canSwitchMapMode`
|
|
256
|
-
- 2D/3D 适配与数据方法:同时导出 `adapters/lr2d`、`adapters/lr3d` 和 `services/gis` 中的方法,适合在需要直接操作底层地图实例或手动加载云 GIS 数据时使用
|
|
257
|
-
|
|
258
|
-
## 公开能力
|
|
259
|
-
|
|
260
|
-
组件 Props:
|
|
261
|
-
|
|
262
|
-
- `mode`
|
|
263
|
-
当前激活模式,支持 `2d` 或 `3d`。
|
|
264
|
-
- `modes`
|
|
265
|
-
当前组件允许启用的模式列表,默认 `['3d']`。
|
|
266
|
-
- `map2dConfig`
|
|
267
|
-
二维图纸运行时配置。
|
|
268
|
-
- `lr3dConfig`
|
|
269
|
-
龙软三维运行时配置。
|
|
270
|
-
- `credentialKey`
|
|
271
|
-
内部凭证解密 Key,二维与三维都会使用它解析内置认证信息。
|
|
272
|
-
- `showRegionPanel`
|
|
273
|
-
是否显示区域显隐面板,默认 `false`。
|
|
274
|
-
- `showDebugPanel`
|
|
275
|
-
是否显示调试面板,默认 `false`。
|
|
276
|
-
- `showMonitorPanel`
|
|
277
|
-
是否显示监测点面板,默认 `false`。
|
|
278
|
-
|
|
279
|
-
组件事件:
|
|
280
|
-
|
|
281
|
-
- `mode-change`
|
|
282
|
-
当前显示模式切换时触发,回调参数结构如下:
|
|
283
|
-
|
|
284
|
-
```js
|
|
285
|
-
{
|
|
286
|
-
mode: '2d' | '3d',
|
|
287
|
-
previousMode: '2d' | '3d',
|
|
288
|
-
supportedModes: ['2d', '3d'],
|
|
289
|
-
}
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
组件 expose:
|
|
293
|
-
|
|
294
|
-
- `switchMode(mode)`
|
|
295
|
-
- `getCurrentMode()`
|
|
296
|
-
- `getCurrentEngine()`
|
|
297
|
-
- `get2dInstance()`
|
|
298
|
-
- `get3dInstance()`
|
|
299
|
-
- `resize()`
|
|
300
|
-
- `refreshScene()`
|
|
301
|
-
- `registerModelInfoQuery(callback)`
|
|
302
|
-
|
|
303
|
-
说明:
|
|
304
|
-
|
|
305
|
-
- `switchMode(mode)` 支持在 `2d / 3d` 间切换当前显示引擎。
|
|
306
|
-
- `get2dInstance()` 返回当前二维 adapter 实例,其中包含 `map`、`options`、`behavior`、`layerTree` 等信息。
|
|
307
|
-
- `refreshScene()` 仅对三维场景有效。
|
|
308
|
-
- `registerModelInfoQuery(callback)` 会在用户点击三维中的模型对象时触发回调。
|
|
309
|
-
- 模型信息查询返回 4 个字段:`id`、`name`、`layerName`、`position`。
|
|
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
|
-
- `
|
|
379
|
-
- `
|
|
380
|
-
- `
|
|
381
|
-
- `
|
|
382
|
-
- `
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
- `
|
|
388
|
-
- `
|
|
389
|
-
- `
|
|
390
|
-
- `
|
|
391
|
-
- `
|
|
392
|
-
- `
|
|
393
|
-
- `
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
- `map2dConfig.options.
|
|
435
|
-
|
|
436
|
-
- `map2dConfig.options.
|
|
437
|
-
|
|
438
|
-
- `map2dConfig.options.
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
- `map2dConfig.options.
|
|
452
|
-
|
|
453
|
-
- `map2dConfig.
|
|
454
|
-
|
|
455
|
-
- `map2dConfig.behavior.
|
|
456
|
-
|
|
457
|
-
- `map2dConfig.behavior.
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
<button type="button" @click="
|
|
504
|
-
<button type="button" @click="
|
|
505
|
-
<button type="button" @click="
|
|
506
|
-
<button type="button" @click="
|
|
507
|
-
<
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
<button type="button" @click="
|
|
542
|
-
<
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
viewerRef
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
)
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
</
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
<
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
- `
|
|
701
|
-
|
|
702
|
-
- `cloud.
|
|
703
|
-
|
|
704
|
-
- `cloud.
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
- `
|
|
720
|
-
|
|
721
|
-
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
```
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
1.
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
1.
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
###
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
1
|
+
# @zhangdali1996/lr-map-viewer
|
|
2
|
+
|
|
3
|
+
`@zhangdali1996/lr-map-viewer` 是面向 Vue 3 项目的三维地图组件库,提供龙软三维场景承载能力,以及基于组件实例的视角控制与模型信息查询能力。
|
|
4
|
+
|
|
5
|
+
主要能力:
|
|
6
|
+
|
|
7
|
+
- 支持 Vue 3 项目中以组件方式挂载二维图纸容器。
|
|
8
|
+
- 支持 Vue 3 项目中以组件方式挂载三维地图容器。
|
|
9
|
+
- 支持 `2d / 3d` 模式切换与统一壳层承载。
|
|
10
|
+
- 支持龙软三维 SDK 的运行时加载。
|
|
11
|
+
- 支持通过运行时配置传入二维图纸参数。
|
|
12
|
+
- 支持通过运行时配置传入云 GIS 参数。
|
|
13
|
+
- 支持通过运行时配置显式传入三维场景 `basePoint`。
|
|
14
|
+
- 支持按需显示区域显隐面板、调试面板和监测点面板。
|
|
15
|
+
- 支持通过组件实例调用 `moveView(x, y, z)` 移动三维视角。
|
|
16
|
+
- 支持通过组件实例保存/恢复视角,以及控制演示人员的初始化、运动和聚焦。
|
|
17
|
+
- 支持通过组件实例注册 `registerModelInfoQuery(callback)` 查询点击模型信息。
|
|
18
|
+
|
|
19
|
+
## 安装
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @zhangdali1996/lr-map-viewer
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`vue` 和 `element-plus` 作为 `peerDependencies` 提供,要求使用方项目自行安装。
|
|
26
|
+
|
|
27
|
+
二维图纸依赖的 `@longruan/lr-map` 已随当前组件库构建产物内置,客户项目安装本包时不需要再额外访问公司内网 npm 拉取这个依赖。
|
|
28
|
+
|
|
29
|
+
安装后请显式引入组件库样式:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import '@zhangdali1996/lr-map-viewer/style.css'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
说明:
|
|
36
|
+
|
|
37
|
+
- 这部分样式对应组件库自身的布局、面板、占位态等 UI。
|
|
38
|
+
- 龙软 SDK 的 `/editorapp`、`/resource` 静态资源及其中的样式,仍需由实施方单独提供。
|
|
39
|
+
|
|
40
|
+
## 静态资源放置
|
|
41
|
+
|
|
42
|
+
该包不会携带龙软 SDK 的大体积静态资源。以下目录需要由实施方单独提供给客户:
|
|
43
|
+
|
|
44
|
+
- `editorapp`
|
|
45
|
+
- `resource`
|
|
46
|
+
|
|
47
|
+
推荐放置到客户项目的 `public` 目录:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
public/
|
|
51
|
+
editorapp/
|
|
52
|
+
resource/
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
对应默认访问路径:
|
|
56
|
+
|
|
57
|
+
- `/editorapp/editorapp.bundle.js`
|
|
58
|
+
- `/resource/js/three.min.js`
|
|
59
|
+
- `/resource/js/vue.2.6.11.js`
|
|
60
|
+
- `/resource/js/element_ui.js`
|
|
61
|
+
- `/resource/js/jquery-3.1.1.min.js`
|
|
62
|
+
|
|
63
|
+
如果客户项目的静态资源目录不是根路径,需要通过 `lr3dConfig.sdk` 自定义覆盖路径。
|
|
64
|
+
|
|
65
|
+
如果客户项目把龙软静态资源统一挂在某个业务前缀下,也可以只传 `sdk.resourcePrefix`,让组件自动给默认的 `/editorapp` 和 `/resource` 路径补前缀。
|
|
66
|
+
|
|
67
|
+
例如:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
const lr3dConfig = {
|
|
71
|
+
sdk: {
|
|
72
|
+
resourcePrefix: 'gkpt',
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
会自动解析为:
|
|
78
|
+
|
|
79
|
+
- `/gkpt/editorapp/editorapp.bundle.js`
|
|
80
|
+
- `/gkpt/resource/js/three.min.js`
|
|
81
|
+
- `/gkpt/resource/js/vue.2.6.11.js`
|
|
82
|
+
- `/gkpt/resource/js/element_ui.js`
|
|
83
|
+
- `/gkpt/resource/js/jquery-3.1.1.min.js`
|
|
84
|
+
|
|
85
|
+
说明:
|
|
86
|
+
|
|
87
|
+
- 不传 `sdk.resourcePrefix` 时,默认仍然使用 `/editorapp` 和 `/resource`
|
|
88
|
+
- 支持传 `gkpt`、`/gkpt`、`gkpt/`、`/gkpt/`,最终都会归一化为 `/gkpt`
|
|
89
|
+
- 如果你已经显式传了完整的 `sdk.scriptSrc` 或 `sdk.dependencies[].src`,则建议直接传最终路径
|
|
90
|
+
|
|
91
|
+
## 最小接入示例
|
|
92
|
+
|
|
93
|
+
### 三维示例
|
|
94
|
+
|
|
95
|
+
```vue
|
|
96
|
+
<script setup>
|
|
97
|
+
import '@zhangdali1996/lr-map-viewer/style.css'
|
|
98
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
99
|
+
|
|
100
|
+
const credentialKey = 'your_credential_key'
|
|
101
|
+
|
|
102
|
+
const lr3dConfig = {
|
|
103
|
+
// 是否在场景初始化成功后自动加载云 GIS 数据
|
|
104
|
+
autoLoad: true,
|
|
105
|
+
cloud: {
|
|
106
|
+
// 数据源 guid
|
|
107
|
+
dsGuid: 'your_ds_guid',
|
|
108
|
+
// 三维场景基点
|
|
109
|
+
basePoint: {
|
|
110
|
+
x: 37517614.46684,
|
|
111
|
+
y: 4410289.679932,
|
|
112
|
+
z: 972.148557,
|
|
113
|
+
},
|
|
114
|
+
// 需要加载的巷道图层名
|
|
115
|
+
layers: ['your_lane_layer_name'],
|
|
116
|
+
laneSize: {
|
|
117
|
+
// 巷道渲染宽度
|
|
118
|
+
width: 10,
|
|
119
|
+
// 巷道渲染高度
|
|
120
|
+
height: 10,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
}
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<template>
|
|
127
|
+
<div style="height: 100vh;">
|
|
128
|
+
<LrMapViewer :lr3d-config="lr3dConfig" :credential-key="credentialKey" />
|
|
129
|
+
</div>
|
|
130
|
+
</template>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 二维图纸示例
|
|
134
|
+
|
|
135
|
+
```vue
|
|
136
|
+
<script setup>
|
|
137
|
+
import '@zhangdali1996/lr-map-viewer/style.css'
|
|
138
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
139
|
+
|
|
140
|
+
const credentialKey = 'your_credential_key'
|
|
141
|
+
|
|
142
|
+
const map2dConfig = {
|
|
143
|
+
behavior: {
|
|
144
|
+
autoInitLayer: true,
|
|
145
|
+
autoShowLayer: true,
|
|
146
|
+
captureLayerTree: true,
|
|
147
|
+
},
|
|
148
|
+
options: {
|
|
149
|
+
ygis_dsGuid: 'your_ds_guid',
|
|
150
|
+
layerName: 'your_layer_name',
|
|
151
|
+
layerCode: '',
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<template>
|
|
157
|
+
<div style="height: 100vh;">
|
|
158
|
+
<LrMapViewer
|
|
159
|
+
mode="2d"
|
|
160
|
+
:modes="['2d']"
|
|
161
|
+
:map2d-config="map2dConfig"
|
|
162
|
+
:credential-key="credentialKey"
|
|
163
|
+
/>
|
|
164
|
+
</div>
|
|
165
|
+
</template>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 二维三维切换示例
|
|
169
|
+
|
|
170
|
+
```vue
|
|
171
|
+
<script setup>
|
|
172
|
+
import { ref } from 'vue'
|
|
173
|
+
import '@zhangdali1996/lr-map-viewer/style.css'
|
|
174
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
175
|
+
|
|
176
|
+
const activeMode = ref('2d')
|
|
177
|
+
const credentialKey = 'your_credential_key'
|
|
178
|
+
|
|
179
|
+
const map2dConfig = {
|
|
180
|
+
options: {
|
|
181
|
+
ygis_dsGuid: 'your_ds_guid',
|
|
182
|
+
layerName: 'your_layer_name',
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const lr3dConfig = {
|
|
187
|
+
autoLoad: true,
|
|
188
|
+
cloud: {
|
|
189
|
+
dsGuid: 'your_ds_guid',
|
|
190
|
+
basePoint: {
|
|
191
|
+
x: 37517614.46684,
|
|
192
|
+
y: 4410289.679932,
|
|
193
|
+
z: 972.148557,
|
|
194
|
+
},
|
|
195
|
+
layers: ['your_lane_layer_name'],
|
|
196
|
+
},
|
|
197
|
+
}
|
|
198
|
+
</script>
|
|
199
|
+
|
|
200
|
+
<template>
|
|
201
|
+
<div style="height: 100vh;">
|
|
202
|
+
<LrMapViewer
|
|
203
|
+
:mode="activeMode"
|
|
204
|
+
:modes="['2d', '3d']"
|
|
205
|
+
:map2d-config="map2dConfig"
|
|
206
|
+
:lr3d-config="lr3dConfig"
|
|
207
|
+
:credential-key="credentialKey"
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
</template>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
如果你需要默认显示右上角区域显隐面板和调试面板:
|
|
214
|
+
|
|
215
|
+
```vue
|
|
216
|
+
<LrMapViewer
|
|
217
|
+
:lr3d-config="lr3dConfig"
|
|
218
|
+
:credential-key="credentialKey"
|
|
219
|
+
:show-region-panel="true"
|
|
220
|
+
:show-debug-panel="true"
|
|
221
|
+
/>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
说明:
|
|
225
|
+
|
|
226
|
+
- 三维组件已内置默认的 `sdk`、`scene`、`initOptions`、`dataSource.type`、`dataSource.loadMode` 配置,通常不需要手动传入。
|
|
227
|
+
- 推荐只传 `autoLoad` 和 `cloud` 下的业务参数即可。
|
|
228
|
+
- 如果你有特殊需求,仍然可以继续传完整的 `lr3dConfig` 结构来覆盖默认值。
|
|
229
|
+
|
|
230
|
+
## 推荐接入方式
|
|
231
|
+
|
|
232
|
+
推荐直接按需引入组件:
|
|
233
|
+
|
|
234
|
+
```js
|
|
235
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
也支持作为插件安装:
|
|
239
|
+
|
|
240
|
+
```js
|
|
241
|
+
import { createApp } from 'vue'
|
|
242
|
+
import LrMapViewerPlugin from '@zhangdali1996/lr-map-viewer'
|
|
243
|
+
import App from './App.vue'
|
|
244
|
+
|
|
245
|
+
createApp(App).use(LrMapViewerPlugin).mount('#app')
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## 命名导出
|
|
249
|
+
|
|
250
|
+
除默认导出的插件对象外,包入口还提供以下命名导出:
|
|
251
|
+
|
|
252
|
+
- 组件:`LrMapViewer`、`Lr2dViewer`、`Lr3dViewer`
|
|
253
|
+
- 2D 配置工具:`getDefaultLr2dConfig`、`getLr2dConfig`、`getLr2dMapOptions`、`setLr2dConfig`、`resetLr2dConfig`、`resolveLr2dConfig`、`getMissingLr2dOptionFields`、`getRequiredLr2dOptionFields`、`isLr2dConfigReady`
|
|
254
|
+
- 3D 配置工具:`getDefaultLr3dConfig`、`getLr3dConfig`、`setLr3dConfig`、`resetLr3dConfig`、`resolveLr3dConfig`
|
|
255
|
+
- 模式工具:`getSupportedMapModes`、`normalizeMapMode`、`resolveMapModes`、`resolveInitialMapMode`、`canSwitchMapMode`
|
|
256
|
+
- 2D/3D 适配与数据方法:同时导出 `adapters/lr2d`、`adapters/lr3d` 和 `services/gis` 中的方法,适合在需要直接操作底层地图实例或手动加载云 GIS 数据时使用
|
|
257
|
+
|
|
258
|
+
## 公开能力
|
|
259
|
+
|
|
260
|
+
组件 Props:
|
|
261
|
+
|
|
262
|
+
- `mode`
|
|
263
|
+
当前激活模式,支持 `2d` 或 `3d`。
|
|
264
|
+
- `modes`
|
|
265
|
+
当前组件允许启用的模式列表,默认 `['3d']`。
|
|
266
|
+
- `map2dConfig`
|
|
267
|
+
二维图纸运行时配置。
|
|
268
|
+
- `lr3dConfig`
|
|
269
|
+
龙软三维运行时配置。
|
|
270
|
+
- `credentialKey`
|
|
271
|
+
内部凭证解密 Key,二维与三维都会使用它解析内置认证信息。
|
|
272
|
+
- `showRegionPanel`
|
|
273
|
+
是否显示区域显隐面板,默认 `false`。
|
|
274
|
+
- `showDebugPanel`
|
|
275
|
+
是否显示调试面板,默认 `false`。
|
|
276
|
+
- `showMonitorPanel`
|
|
277
|
+
是否显示监测点面板,默认 `false`。
|
|
278
|
+
|
|
279
|
+
组件事件:
|
|
280
|
+
|
|
281
|
+
- `mode-change`
|
|
282
|
+
当前显示模式切换时触发,回调参数结构如下:
|
|
283
|
+
|
|
284
|
+
```js
|
|
285
|
+
{
|
|
286
|
+
mode: '2d' | '3d',
|
|
287
|
+
previousMode: '2d' | '3d',
|
|
288
|
+
supportedModes: ['2d', '3d'],
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
组件 expose:
|
|
293
|
+
|
|
294
|
+
- `switchMode(mode)`
|
|
295
|
+
- `getCurrentMode()`
|
|
296
|
+
- `getCurrentEngine()`
|
|
297
|
+
- `get2dInstance()`
|
|
298
|
+
- `get3dInstance()`
|
|
299
|
+
- `resize()`
|
|
300
|
+
- `refreshScene()`
|
|
301
|
+
- `registerModelInfoQuery(callback)`
|
|
302
|
+
|
|
303
|
+
说明:
|
|
304
|
+
|
|
305
|
+
- `switchMode(mode)` 支持在 `2d / 3d` 间切换当前显示引擎。
|
|
306
|
+
- `get2dInstance()` 返回当前二维 adapter 实例,其中包含 `map`、`options`、`behavior`、`layerTree` 等信息。
|
|
307
|
+
- `refreshScene()` 仅对三维场景有效。
|
|
308
|
+
- `registerModelInfoQuery(callback)` 会在用户点击三维中的模型对象时触发回调。
|
|
309
|
+
- 模型信息查询返回 4 个字段:`id`、`name`、`layerName`、`position`。
|
|
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
|
+
- `setRangeSelectionByCoordinate(center, options)`
|
|
379
|
+
- `setRangeSelectionRadius(radius)`
|
|
380
|
+
- `clearRangeSelection()`
|
|
381
|
+
- `getRangeSelectionResult()`
|
|
382
|
+
- `registerRangeSelectionChange(callback)`
|
|
383
|
+
- `focusMonitorPoint(target)`
|
|
384
|
+
|
|
385
|
+
说明:
|
|
386
|
+
|
|
387
|
+
- `startRangeSelection(options)` 用于启动范围选点,支持通过 `options.radius` 指定初始半径。
|
|
388
|
+
- `cancelRangeSelection(options)` 用于取消当前范围选点,可通过 `options.preserveCurrentResult` 控制是否保留当前结果。
|
|
389
|
+
- `setRangeSelection(center, options)` 用于直接传入三维坐标生成球形范围,适合业务系统通过外部坐标直接驱动范围选点。
|
|
390
|
+
- `setRangeSelectionByCoordinate(center, options)` 用于通过外部接口传入坐标生成球形范围,内部复用 `setRangeSelection` 的范围绘制、测点过滤和回调链路。
|
|
391
|
+
- `setRangeSelectionRadius(radius)` 用于更新当前范围半径;如果当前已完成选点,会同步更新球体和范围内测点。
|
|
392
|
+
- `clearRangeSelection()` 用于清除当前范围球、选点标记和测点过滤结果。
|
|
393
|
+
- `getRangeSelectionResult()` 返回当前范围选点结果,包含状态、半径、球心坐标、当前巷道信息和范围内测点列表。
|
|
394
|
+
- `registerRangeSelectionChange(callback)` 会在开始选点、选点完成、半径变化、取消、清除时触发回调。
|
|
395
|
+
- `focusMonitorPoint(target)` 用于定位并打开指定测点的信息窗,支持传测点 `id` 或测点对象。
|
|
396
|
+
|
|
397
|
+
## 二维图纸配置说明
|
|
398
|
+
|
|
399
|
+
推荐写法:
|
|
400
|
+
|
|
401
|
+
```js
|
|
402
|
+
const map2dConfig = {
|
|
403
|
+
behavior: {
|
|
404
|
+
autoInitLayer: true,
|
|
405
|
+
autoShowLayer: true,
|
|
406
|
+
captureLayerTree: true,
|
|
407
|
+
},
|
|
408
|
+
options: {
|
|
409
|
+
ygis_dsGuid: 'your_ds_guid',
|
|
410
|
+
ygis_url: 'https://your-cloud-gis-server/',
|
|
411
|
+
Url: 'https://your-map-server/',
|
|
412
|
+
layerName: 'your_layer_name',
|
|
413
|
+
layerCode: '',
|
|
414
|
+
token: 'your_token',
|
|
415
|
+
extent: '',
|
|
416
|
+
rotate: false,
|
|
417
|
+
animate: false,
|
|
418
|
+
zoomAnimation: false,
|
|
419
|
+
markerZoomAnimation: false,
|
|
420
|
+
fadeAnimation: false,
|
|
421
|
+
},
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
推荐接入方式分为两种:
|
|
426
|
+
|
|
427
|
+
- 通过 `credentialKey` 接入:
|
|
428
|
+
组件会自动补齐 `ygis_url`、`map_server_url/Url`、`ygis_username`、`ygis_password`,此时你通常只需要传业务相关字段,例如 `ygis_dsGuid`、`layerName`、`layerCode`。
|
|
429
|
+
- 不通过 `credentialKey`,直接手动传完整二维配置:
|
|
430
|
+
需要自行补齐地址和认证信息。
|
|
431
|
+
|
|
432
|
+
手动直传完整二维配置时的必填字段:
|
|
433
|
+
|
|
434
|
+
- `map2dConfig.options.ygis_dsGuid`
|
|
435
|
+
二维图纸数据源 guid。
|
|
436
|
+
- `map2dConfig.options.ygis_url`
|
|
437
|
+
云 GIS 服务地址。
|
|
438
|
+
- `map2dConfig.options.Url`
|
|
439
|
+
二维地图服务地址。
|
|
440
|
+
- `map2dConfig.options.token`
|
|
441
|
+
二维认证 token,和用户名密码二选一。
|
|
442
|
+
|
|
443
|
+
认证兼容说明:
|
|
444
|
+
|
|
445
|
+
- 如果没有 `token`,则需要同时传入 `map2dConfig.options.ygis_username` 和 `map2dConfig.options.ygis_password`。
|
|
446
|
+
- `map2dConfig.options.map_server_url` 与 `map2dConfig.options.Url` 在组件内部会自动对齐,二者传一个即可。
|
|
447
|
+
- 当 `map2dConfig.behavior.autoShowLayer` 为 `true` 时,`map2dConfig.options.layerName` 也属于必填项。
|
|
448
|
+
|
|
449
|
+
常用可选字段:
|
|
450
|
+
|
|
451
|
+
- `map2dConfig.options.layerCode`
|
|
452
|
+
图层编码,默认可传空字符串。
|
|
453
|
+
- `map2dConfig.options.extent`
|
|
454
|
+
初始范围。
|
|
455
|
+
- `map2dConfig.behavior.autoInitLayer`
|
|
456
|
+
是否自动初始化图层,默认 `true`。
|
|
457
|
+
- `map2dConfig.behavior.autoShowLayer`
|
|
458
|
+
是否自动显示指定图层,默认 `true`。
|
|
459
|
+
- `map2dConfig.behavior.captureLayerTree`
|
|
460
|
+
是否抓取图层树,默认 `true`。
|
|
461
|
+
|
|
462
|
+
## 接口示例
|
|
463
|
+
|
|
464
|
+
推荐通过 `ref` 调用组件实例方法:
|
|
465
|
+
|
|
466
|
+
### 监测点模块示例
|
|
467
|
+
|
|
468
|
+
```vue
|
|
469
|
+
<script setup>
|
|
470
|
+
import { ref } from 'vue'
|
|
471
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
472
|
+
|
|
473
|
+
const viewerRef = ref(null)
|
|
474
|
+
|
|
475
|
+
async function handleInitMonitorPoints() {
|
|
476
|
+
await viewerRef.value?.initMonitorPoints?.()
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
async function handleReloadMonitorPoints() {
|
|
480
|
+
await viewerRef.value?.reloadMonitorPoints?.()
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
async function handleQueryMonitorPoints() {
|
|
484
|
+
const list = await viewerRef.value?.queryMonitorPointList?.()
|
|
485
|
+
console.log('monitor points', list)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function handleFocusMonitorPoint() {
|
|
489
|
+
viewerRef.value?.focusMonitorPoint?.('mock-monitor-point-1')
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function handleFocusPerson() {
|
|
493
|
+
viewerRef.value?.focusPerson?.()
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function handleMovePerson() {
|
|
497
|
+
viewerRef.value?.movePerson?.()
|
|
498
|
+
}
|
|
499
|
+
</script>
|
|
500
|
+
|
|
501
|
+
<template>
|
|
502
|
+
<div style="height: 100vh;">
|
|
503
|
+
<button type="button" @click="handleInitMonitorPoints">初始化监测点</button>
|
|
504
|
+
<button type="button" @click="handleReloadMonitorPoints">重新加载监测点</button>
|
|
505
|
+
<button type="button" @click="handleQueryMonitorPoints">查询监测点</button>
|
|
506
|
+
<button type="button" @click="handleFocusMonitorPoint">聚焦监测点</button>
|
|
507
|
+
<button type="button" @click="handleFocusPerson">聚焦人员</button>
|
|
508
|
+
<button type="button" @click="handleMovePerson">人员移动</button>
|
|
509
|
+
<LrMapViewer ref="viewerRef" :lr3d-config="lr3dConfig" />
|
|
510
|
+
</div>
|
|
511
|
+
</template>
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### 视角控制模块示例
|
|
515
|
+
|
|
516
|
+
```vue
|
|
517
|
+
<script setup>
|
|
518
|
+
import { ref } from 'vue'
|
|
519
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
520
|
+
|
|
521
|
+
const viewerRef = ref(null)
|
|
522
|
+
const currentViewInfo = ref(null)
|
|
523
|
+
|
|
524
|
+
function handleSwitchViewPoint() {
|
|
525
|
+
viewerRef.value?.switchToViewPoint?.('井口')
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function handleCaptureViewInfo() {
|
|
529
|
+
currentViewInfo.value = viewerRef.value?.getCurrentViewInfo?.() ?? null
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function handleRestoreViewInfo() {
|
|
533
|
+
if (currentViewInfo.value) {
|
|
534
|
+
viewerRef.value?.applyViewInfo?.(currentViewInfo.value)
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
</script>
|
|
538
|
+
|
|
539
|
+
<template>
|
|
540
|
+
<div style="height: 100vh;">
|
|
541
|
+
<button type="button" @click="handleSwitchViewPoint">切换到井口视角</button>
|
|
542
|
+
<button type="button" @click="handleCaptureViewInfo">读取当前视口</button>
|
|
543
|
+
<button type="button" @click="handleRestoreViewInfo">按视角参数恢复</button>
|
|
544
|
+
<LrMapViewer ref="viewerRef" :lr3d-config="lr3dConfig" />
|
|
545
|
+
</div>
|
|
546
|
+
</template>
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
### 范围选点模块示例
|
|
550
|
+
|
|
551
|
+
如果你需要通过组件实例控制范围选点:
|
|
552
|
+
|
|
553
|
+
```vue
|
|
554
|
+
<script setup>
|
|
555
|
+
import { ref, watch } from 'vue'
|
|
556
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
557
|
+
|
|
558
|
+
const viewerRef = ref(null)
|
|
559
|
+
|
|
560
|
+
function startRangeSelection() {
|
|
561
|
+
viewerRef.value?.startRangeSelection?.({
|
|
562
|
+
radius: 500,
|
|
563
|
+
})
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function setRangeSelectionByCoordinate() {
|
|
567
|
+
viewerRef.value?.setRangeSelectionByCoordinate?.(
|
|
568
|
+
{ x: 37515615.6365, y: 4412429.261443, z: 1270.872 },
|
|
569
|
+
{ radius: 500 },
|
|
570
|
+
)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function clearRangeSelection() {
|
|
574
|
+
viewerRef.value?.clearRangeSelection?.()
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
function focusFirstMonitorPoint() {
|
|
578
|
+
const result = viewerRef.value?.getRangeSelectionResult?.()
|
|
579
|
+
const firstMonitorPoint = result?.monitorPoints?.[0]
|
|
580
|
+
|
|
581
|
+
if (firstMonitorPoint) {
|
|
582
|
+
viewerRef.value?.focusMonitorPoint?.(firstMonitorPoint)
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
watch(
|
|
587
|
+
viewerRef,
|
|
588
|
+
(viewer) => {
|
|
589
|
+
if (!viewer?.registerRangeSelectionChange) {
|
|
590
|
+
return
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
viewer.registerRangeSelectionChange((payload) => {
|
|
594
|
+
console.log('range selection', payload)
|
|
595
|
+
})
|
|
596
|
+
},
|
|
597
|
+
{ immediate: true },
|
|
598
|
+
)
|
|
599
|
+
</script>
|
|
600
|
+
|
|
601
|
+
<template>
|
|
602
|
+
<div style="height: 100vh;">
|
|
603
|
+
<button type="button" @click="startRangeSelection">开始范围选点</button>
|
|
604
|
+
<button type="button" @click="setRangeSelectionByCoordinate">按坐标生成范围</button>
|
|
605
|
+
<button type="button" @click="clearRangeSelection">清除范围</button>
|
|
606
|
+
<button type="button" @click="focusFirstMonitorPoint">定位首个测点</button>
|
|
607
|
+
<LrMapViewer ref="viewerRef" :lr3d-config="lr3dConfig" />
|
|
608
|
+
</div>
|
|
609
|
+
</template>
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
如果你需要切换二维与三维模式:
|
|
613
|
+
|
|
614
|
+
```vue
|
|
615
|
+
<script setup>
|
|
616
|
+
import { ref } from 'vue'
|
|
617
|
+
import { LrMapViewer } from '@zhangdali1996/lr-map-viewer'
|
|
618
|
+
|
|
619
|
+
const viewerRef = ref(null)
|
|
620
|
+
|
|
621
|
+
function switchTo2d() {
|
|
622
|
+
viewerRef.value?.switchMode?.('2d')
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function switchTo3d() {
|
|
626
|
+
viewerRef.value?.switchMode?.('3d')
|
|
627
|
+
}
|
|
628
|
+
</script>
|
|
629
|
+
|
|
630
|
+
<template>
|
|
631
|
+
<div style="height: 100vh;">
|
|
632
|
+
<button type="button" @click="switchTo2d">查看二维</button>
|
|
633
|
+
<button type="button" @click="switchTo3d">查看三维</button>
|
|
634
|
+
<LrMapViewer
|
|
635
|
+
ref="viewerRef"
|
|
636
|
+
:modes="['2d', '3d']"
|
|
637
|
+
:map2d-config="map2dConfig"
|
|
638
|
+
:lr3d-config="lr3dConfig"
|
|
639
|
+
/>
|
|
640
|
+
</div>
|
|
641
|
+
</template>
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
模型信息查询回调返回结构:
|
|
645
|
+
|
|
646
|
+
```js
|
|
647
|
+
{
|
|
648
|
+
// 模型或实体标识
|
|
649
|
+
id: '...',
|
|
650
|
+
// 模型或实体名称
|
|
651
|
+
name: '...',
|
|
652
|
+
// 所属图层名
|
|
653
|
+
layerName: '...',
|
|
654
|
+
position: {
|
|
655
|
+
// 模型本地坐标 x
|
|
656
|
+
x: 0,
|
|
657
|
+
// 模型本地坐标 y
|
|
658
|
+
y: 0,
|
|
659
|
+
// 模型本地坐标 z
|
|
660
|
+
z: 0,
|
|
661
|
+
},
|
|
662
|
+
}
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
## 云 GIS 配置说明
|
|
666
|
+
|
|
667
|
+
推荐写法:
|
|
668
|
+
|
|
669
|
+
```js
|
|
670
|
+
const lr3dConfig = {
|
|
671
|
+
autoLoad: true,
|
|
672
|
+
cloud: {
|
|
673
|
+
server: 'https://your-cloud-gis-server/',
|
|
674
|
+
username: 'your_username',
|
|
675
|
+
password: 'your_password',
|
|
676
|
+
dsGuid: 'your_ds_guid',
|
|
677
|
+
basePoint: {
|
|
678
|
+
x: 37517614.46684,
|
|
679
|
+
y: 4410289.679932,
|
|
680
|
+
z: 972.148557,
|
|
681
|
+
},
|
|
682
|
+
layers: ['your_lane_layer_name'],
|
|
683
|
+
laneSize: {
|
|
684
|
+
width: 10,
|
|
685
|
+
height: 10,
|
|
686
|
+
},
|
|
687
|
+
},
|
|
688
|
+
}
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
推荐接入方式同样分为两种:
|
|
692
|
+
|
|
693
|
+
- 通过 `credentialKey` 接入:
|
|
694
|
+
组件会自动补齐 `cloud.server`、`cloud.username`、`cloud.password`,此时你通常只需要传 `autoLoad`、`cloud.dsGuid`、`cloud.basePoint` 以及业务图层参数。
|
|
695
|
+
- 不通过 `credentialKey`,直接手动传完整三维配置:
|
|
696
|
+
需要自行补齐三维服务地址和认证信息。
|
|
697
|
+
|
|
698
|
+
手动直传完整三维配置时的必填字段:
|
|
699
|
+
|
|
700
|
+
- `autoLoad`
|
|
701
|
+
是否在场景初始化成功后自动加载云 GIS 数据。
|
|
702
|
+
- `cloud.server`
|
|
703
|
+
云 GIS 服务地址。
|
|
704
|
+
- `cloud.username`
|
|
705
|
+
云 GIS 用户名。
|
|
706
|
+
- `cloud.password`
|
|
707
|
+
云 GIS 密码。
|
|
708
|
+
- `cloud.dsGuid`
|
|
709
|
+
数据源 guid。
|
|
710
|
+
- `cloud.basePoint.x`
|
|
711
|
+
三维场景基点 x 坐标。
|
|
712
|
+
- `cloud.basePoint.y`
|
|
713
|
+
三维场景基点 y 坐标。
|
|
714
|
+
- `cloud.basePoint.z`
|
|
715
|
+
三维场景基点 z 坐标。
|
|
716
|
+
|
|
717
|
+
可选字段:
|
|
718
|
+
|
|
719
|
+
- `cloud.layers`
|
|
720
|
+
需要加载的巷道图层名数组。
|
|
721
|
+
- `cloud.laneSize.width`
|
|
722
|
+
巷道渲染宽度,默认 `10`
|
|
723
|
+
- `cloud.laneSize.height`
|
|
724
|
+
巷道渲染高度,默认 `10`
|
|
725
|
+
|
|
726
|
+
兼容说明:
|
|
727
|
+
|
|
728
|
+
- 组件内部仍兼容完整的 `lr3dConfig` 写法。
|
|
729
|
+
- `basePoint` 推荐传入 `{ x, y, z }` 对象。
|
|
730
|
+
- `sdk.resourcePrefix` 可用于统一给默认的 `/editorapp` 与 `/resource` 路径增加业务前缀,例如 `gkpt -> /gkpt/editorapp/...`、`/gkpt/resource/...`。
|
|
731
|
+
- 如果你需要覆盖 SDK 路径、容器参数、初始化参数等高级配置,仍然可以继续传入 `sdk`、`scene`、`initOptions`、`dataSource` 完整结构。
|
|
732
|
+
|
|
733
|
+
## 示例配置
|
|
734
|
+
|
|
735
|
+
下面这份三维配置可直接作为联调参考:
|
|
736
|
+
|
|
737
|
+
```js
|
|
738
|
+
const playgroundLr3dConfig = {
|
|
739
|
+
autoLoad: true,
|
|
740
|
+
cloud: {
|
|
741
|
+
server: 'https://your-cloud-gis-server/',
|
|
742
|
+
username: 'your_username',
|
|
743
|
+
password: 'your_password',
|
|
744
|
+
dsGuid: 'your_ds_guid',
|
|
745
|
+
basePoint: {
|
|
746
|
+
x: 37517614.46684,
|
|
747
|
+
y: 4410289.679932,
|
|
748
|
+
z: 972.148557,
|
|
749
|
+
},
|
|
750
|
+
layers: ['your_lane_layer_name'],
|
|
751
|
+
laneSize: {
|
|
752
|
+
width: 10,
|
|
753
|
+
height: 10,
|
|
754
|
+
},
|
|
755
|
+
},
|
|
756
|
+
}
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
## 常见错误排查
|
|
760
|
+
|
|
761
|
+
### 1. 场景初始化失败:SDK 前置依赖加载失败
|
|
762
|
+
|
|
763
|
+
典型错误:
|
|
764
|
+
|
|
765
|
+
```text
|
|
766
|
+
场景初始化失败:SDK 前置依赖加载失败: /resource/js/jquery-3.1.1.min.js
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
排查方向:
|
|
770
|
+
|
|
771
|
+
1. 确认客户项目里确实存在 `public/resource/js/jquery-3.1.1.min.js`。
|
|
772
|
+
2. 确认浏览器访问 `/resource/js/jquery-3.1.1.min.js` 返回 200,而不是 404。
|
|
773
|
+
3. 如果资源目录不在根路径,使用完整 `lr3dConfig.sdk.dependencies` 配置覆盖默认脚本路径。
|
|
774
|
+
4. 确认 `editorapp` 与 `resource` 属于同一套 SDK 版本,不要混用不同批次文件。
|
|
775
|
+
|
|
776
|
+
### 2. 场景初始化失败:未检测到全局对象
|
|
777
|
+
|
|
778
|
+
这类错误通常表示脚本文件虽然加载了,但脚本执行后没有挂出预期全局变量。
|
|
779
|
+
|
|
780
|
+
排查方向:
|
|
781
|
+
|
|
782
|
+
1. 检查使用的 SDK 版本是否与组件默认配置匹配。
|
|
783
|
+
2. 检查脚本是否被浏览器拦截、跨域策略阻止,或返回了错误 HTML 页面。
|
|
784
|
+
3. 检查依赖加载顺序是否正确,前置依赖必须先于 `editorapp.bundle.js` 完成加载。
|
|
785
|
+
|
|
786
|
+
### 3. 云 GIS 数据源配置缺失
|
|
787
|
+
|
|
788
|
+
典型原因:
|
|
789
|
+
|
|
790
|
+
- 组件库默认配置已不再携带真实业务参数。
|
|
791
|
+
- 接入方没有传入 `server`、`username`、`password`、`dsGuid`、`basePoint`。
|
|
792
|
+
|
|
793
|
+
处理方式:
|
|
794
|
+
|
|
795
|
+
- 在 `lr3dConfig.cloud` 中补齐实际项目所需字段。
|