huweili-cesium 1.2.25 → 1.2.27

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
@@ -123,6 +123,7 @@ export function basicConfig() {
123
123
  const mouseController = (map, _mapId, callbacks = {}) => {
124
124
  // 添加右键点击事件监听
125
125
  map.screenSpaceEventHandler.setInputAction((click) => {
126
+ console.log('右键点击事件触发')
126
127
  // 获取点击位置的笛卡尔坐标
127
128
  const cartesian = map.camera.pickEllipsoid(click.position, map.scene.globe.ellipsoid);
128
129
 
@@ -152,23 +153,29 @@ export function basicConfig() {
152
153
  // 添加左键点击事件,用于隐藏弹窗
153
154
  map.screenSpaceEventHandler.setInputAction((click) => {
154
155
  console.log('左键点击事件触发')
156
+ // 获取点击位置的笛卡尔坐标
155
157
  const cartesian = map.camera.pickEllipsoid(click.position, map.scene.globe.ellipsoid);
158
+
156
159
  if (cartesian) {
160
+ // 转换为经纬度
157
161
  const cartographic = Cesium.Cartographic.fromCartesian(cartesian);
158
162
  const lng = Cesium.Math.toDegrees(cartographic.longitude);
159
163
  const lat = Cesium.Math.toDegrees(cartographic.latitude);
160
164
  const height = cartographic.height;
165
+
166
+ console.log('点击位置:', {
167
+ lng: Number(lng),
168
+ lat: Number(lat),
169
+ height: Number(height)
170
+ });
161
171
  callbacks.onLeftClick?.({
162
- mapId: _mapId,
163
- screenPosition: click.position,
164
172
  lng: Number(lng),
165
173
  lat: Number(lat),
166
- height: Number(height),
167
- cartesian,
174
+ height: Number(height)
168
175
  });
169
- } else {
170
- callbacks.onLeftClick?.({ mapId: _mapId, screenPosition: click.position });
176
+
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.27",
4
4
  "description": "基于 Cesium 的地图工具库(无人机态势、轨迹、围栏、工具栏等)",
5
5
  "type": "module",
6
6
  "main": "./index.js",