huweili-cesium 1.2.27 → 1.2.29
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/js/basis.js +7 -12
- package/package.json +1 -1
package/js/basis.js
CHANGED
|
@@ -121,12 +121,15 @@ export function basicConfig() {
|
|
|
121
121
|
* @param map - 地图实例
|
|
122
122
|
*/
|
|
123
123
|
const mouseController = (map, _mapId, callbacks = {}) => {
|
|
124
|
+
// 阻止浏览器默认的右键菜单弹出
|
|
125
|
+
map.scene.canvas.addEventListener('contextmenu', (e) => {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
});
|
|
128
|
+
|
|
124
129
|
// 添加右键点击事件监听
|
|
125
130
|
map.screenSpaceEventHandler.setInputAction((click) => {
|
|
126
|
-
console.log('右键点击事件触发')
|
|
127
131
|
// 获取点击位置的笛卡尔坐标
|
|
128
132
|
const cartesian = map.camera.pickEllipsoid(click.position, map.scene.globe.ellipsoid);
|
|
129
|
-
|
|
130
133
|
if (cartesian) {
|
|
131
134
|
// 转换为经纬度
|
|
132
135
|
const cartographic = Cesium.Cartographic.fromCartesian(cartesian);
|
|
@@ -142,20 +145,14 @@ export function basicConfig() {
|
|
|
142
145
|
cartesian,
|
|
143
146
|
};
|
|
144
147
|
|
|
145
|
-
console.log('
|
|
146
|
-
callbacks.onRightClick?.(position);
|
|
147
|
-
|
|
148
|
-
// 弹出alert显示坐标信息
|
|
149
|
-
// alert(`点击位置坐标:\n经度:${Number(lng).toFixed(6)}\n纬度:${Number(lat).toFixed(6)}\n高度:${Number(height).toFixed(2)}米`);
|
|
148
|
+
console.log('右键点击事件触发,点击位置:', position);
|
|
150
149
|
}
|
|
151
150
|
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
152
151
|
|
|
153
152
|
// 添加左键点击事件,用于隐藏弹窗
|
|
154
153
|
map.screenSpaceEventHandler.setInputAction((click) => {
|
|
155
|
-
console.log('左键点击事件触发')
|
|
156
154
|
// 获取点击位置的笛卡尔坐标
|
|
157
155
|
const cartesian = map.camera.pickEllipsoid(click.position, map.scene.globe.ellipsoid);
|
|
158
|
-
|
|
159
156
|
if (cartesian) {
|
|
160
157
|
// 转换为经纬度
|
|
161
158
|
const cartographic = Cesium.Cartographic.fromCartesian(cartesian);
|
|
@@ -163,7 +160,7 @@ export function basicConfig() {
|
|
|
163
160
|
const lat = Cesium.Math.toDegrees(cartographic.latitude);
|
|
164
161
|
const height = cartographic.height;
|
|
165
162
|
|
|
166
|
-
console.log('
|
|
163
|
+
console.log('左键点击事件触发,点击位置:', {
|
|
167
164
|
lng: Number(lng),
|
|
168
165
|
lat: Number(lat),
|
|
169
166
|
height: Number(height)
|
|
@@ -173,9 +170,7 @@ export function basicConfig() {
|
|
|
173
170
|
lat: Number(lat),
|
|
174
171
|
height: Number(height)
|
|
175
172
|
});
|
|
176
|
-
|
|
177
173
|
}
|
|
178
|
-
|
|
179
174
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
180
175
|
}
|
|
181
176
|
|