//获取四角经纬度
export const fourWind = () => {
// 获取当前视图范围
var extent = viewer.camera.computeViewRectangle();
// 提取四个角的经纬度
var southwest = Cesium.Rectangle.southwest(extent);
var southeast = Cesium.Rectangle.southeast(extent);
var northeast = Cesium.Rectangle.northeast(extent);
var northwest = Cesium.Rectangle.northwest(extent);
return northwest
// 打印经纬度信息
console.log("Southwest Corner: " + Cesium.Math.toDegrees(southwest.longitude) + ", " + Cesium.Math.toDegrees(southwest.latitude));
console.log("Southeast Corner: " + Cesium.Math.toDegrees(southeast.longitude) + ", " + Cesium.Math.toDegrees(southeast.latitude));
console.log("Northeast Corner: " + Cesium.Math.toDegrees(northeast.longitude) + ", " + Cesium.Math.toDegrees(northeast.latitude));
console.log("Northwest Corner: " + Cesium.Math.toDegrees(northwest.longitude) + ", " + Cesium.Math.toDegrees(northwest.latitude));
}
//监听鼠标滚轮事件
export const ScreenSpaceEventHandler = (callback) => {
const handle3D = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handle3D.setInputAction(() => {
console.log(fourWind(), 'yi1')
// var level = Math.ceil(viewer.camera.positionCartographic.height);
// console.log(level,'缩放等级')
// var height = viewer.camera.positionCartographic.height;
// console.log(height,'高度')
callback(fourWind())
}, Cesium.ScreenSpaceEventType.WHEEL);
}
cesium 监听滚轮获取屏幕四角坐标,视角高度,缩放等级
最新推荐文章于 2024-09-30 02:09:07 发布
文章介绍了如何在Cesium地图库中获取视图范围的四个角落的经纬度,并实现了一个屏幕空间事件处理器,当用户滚动鼠标时触发回调函数,输出经纬度信息。
摘要由CSDN通过智能技术生成