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