huweili-cesium 1.2.22 → 1.2.24

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/index.vue CHANGED
@@ -28,7 +28,7 @@ const {
28
28
 
29
29
  const mapStore = useMapStore()
30
30
  const { on: onEvent, off: offEvent } = useEventBus()
31
- const emit = defineEmits(['onload'])
31
+ const emit = defineEmits(['onload', 'rightClick', 'leftClick'])
32
32
  const props = defineProps({
33
33
  options: {
34
34
  type: Object,
@@ -239,7 +239,10 @@ const initCesium = async () => {
239
239
  })
240
240
  }
241
241
 
242
- mouseController(map, props.mapId) // 初始化鼠标控制器
242
+ mouseController(map, props.mapId, {
243
+ onRightClick: (position) => emit('rightClick', position),
244
+ onLeftClick: (event) => emit('leftClick', event),
245
+ }) // 初始化鼠标控制器
243
246
 
244
247
  mapStore.setMapInfo(
245
248
  'center',
package/js/basis.js CHANGED
@@ -120,7 +120,7 @@ export function basicConfig() {
120
120
  * 处理地图上的鼠标事件,包括点击、拖动、缩放等、
121
121
  * @param map - 地图实例
122
122
  */
123
- const mouseController = (map, _mapId) => {
123
+ const mouseController = (map, _mapId, callbacks = {}) => {
124
124
  // 添加右键点击事件监听
125
125
  map.screenSpaceEventHandler.setInputAction((click) => {
126
126
  // 获取点击位置的笛卡尔坐标
@@ -132,12 +132,17 @@ export function basicConfig() {
132
132
  const lng = Cesium.Math.toDegrees(cartographic.longitude);
133
133
  const lat = Cesium.Math.toDegrees(cartographic.latitude);
134
134
  const height = cartographic.height;
135
-
136
- console.log('点击位置:', {
135
+ const position = {
137
136
  lng: Number(lng),
138
137
  lat: Number(lat),
139
- height: Number(height)
140
- });
138
+ height: Number(height),
139
+ mapId: _mapId,
140
+ screenPosition: click.position,
141
+ cartesian,
142
+ };
143
+
144
+ console.log('点击位置:', position);
145
+ callbacks.onRightClick?.(position);
141
146
 
142
147
  // 弹出alert显示坐标信息
143
148
  // alert(`点击位置坐标:\n经度:${Number(lng).toFixed(6)}\n纬度:${Number(lat).toFixed(6)}\n高度:${Number(height).toFixed(2)}米`);
@@ -145,8 +150,9 @@ export function basicConfig() {
145
150
  }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
146
151
 
147
152
  // 添加左键点击事件,用于隐藏弹窗
148
- map.screenSpaceEventHandler.setInputAction(() => {
153
+ map.screenSpaceEventHandler.setInputAction((click) => {
149
154
  console.log('左键点击事件触发')
155
+ callbacks.onLeftClick?.({ mapId: _mapId, screenPosition: click.position });
150
156
  }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
151
157
  }
152
158
 
package/js/labelDiv.js CHANGED
@@ -34,6 +34,9 @@ export function labelDiv() {
34
34
  labelDiv.style.setProperty('--drone-label-bg-color', statusConfig.labelBgColor);
35
35
  }
36
36
 
37
+ // 机巢无人机只展示头顶标签,不允许点击标签弹出可拖拽详情面板
38
+ const isMachineNestDrone = status === DroneStatus.MACHINE_NEST;
39
+
37
40
  // 存储无人机详情面板的位置坐标,用于拖拽功能
38
41
  let new_detailDivLeft = null;
39
42
  let new_detailDivTop = null;
@@ -313,8 +316,8 @@ export function labelDiv() {
313
316
  }
314
317
  };
315
318
 
316
- // 通过无人机id绑定并触发详情面板打开逻辑
317
- const unbindDetailClick = bindDroneLabelDetailHandler({
319
+ // 通过无人机id绑定并触发详情面板打开逻辑(机巢无人机不绑定详情弹窗)
320
+ const unbindDetailClick = isMachineNestDrone ? () => {} : bindDroneLabelDetailHandler({
318
321
  id: labelItem.id,
319
322
  labelEl: labelDiv,
320
323
  openDetail: () => {
@@ -323,11 +326,6 @@ export function labelDiv() {
323
326
  return; // 如果已存在,直接返回,不创建新的
324
327
  }
325
328
 
326
- // 机巢无人机不允许打开详情面板和拖拽
327
- if (status === DroneStatus.MACHINE_NEST) {
328
- return;
329
- }
330
-
331
329
  new_detailDivLeft = null;
332
330
  new_detailDivTop = null;
333
331
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huweili-cesium",
3
- "version": "1.2.22",
3
+ "version": "1.2.24",
4
4
  "description": "基于 Cesium 的地图工具库(无人机态势、轨迹、围栏、工具栏等)",
5
5
  "type": "module",
6
6
  "main": "./index.js",