huweili-cesium 1.2.24 → 1.2.26

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.
Files changed (2) hide show
  1. package/js/basis.js +24 -1
  2. package/package.json +1 -1
package/js/basis.js CHANGED
@@ -152,7 +152,30 @@ export function basicConfig() {
152
152
  // 添加左键点击事件,用于隐藏弹窗
153
153
  map.screenSpaceEventHandler.setInputAction((click) => {
154
154
  console.log('左键点击事件触发')
155
- callbacks.onLeftClick?.({ mapId: _mapId, screenPosition: click.position });
155
+ // 获取点击位置的笛卡尔坐标
156
+ const cartesian = map.camera.pickEllipsoid(click.position, map.scene.globe.ellipsoid);
157
+
158
+ if (cartesian) {
159
+ // 转换为经纬度
160
+ const cartographic = Cesium.Cartographic.fromCartesian(cartesian);
161
+ const lng = Cesium.Math.toDegrees(cartographic.longitude);
162
+ const lat = Cesium.Math.toDegrees(cartographic.latitude);
163
+ const height = cartographic.height;
164
+
165
+ console.log('点击位置:', {
166
+ lng: Number(lng),
167
+ lat: Number(lat),
168
+ height: Number(height)
169
+ });
170
+ callbacks.onLeftClick?.({
171
+ lng: Number(lng),
172
+ lat: Number(lat),
173
+ height: Number(height)
174
+ });
175
+ // 弹出alert显示坐标信息
176
+ // alert(`点击位置坐标:\n经度:${Number(lng).toFixed(6)}\n纬度:${Number(lat).toFixed(6)}\n高度:${Number(height).toFixed(2)}米`);
177
+ }
178
+
156
179
  }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
157
180
  }
158
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huweili-cesium",
3
- "version": "1.2.24",
3
+ "version": "1.2.26",
4
4
  "description": "基于 Cesium 的地图工具库(无人机态势、轨迹、围栏、工具栏等)",
5
5
  "type": "module",
6
6
  "main": "./index.js",