标签:screen cti ips globe 地图 can div 获取 hand
将以下代码放入到初始化加载三维地图以后,点击地图即可获取经纬度:
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas); var that = this; handler.setInputAction(function(e) { var position = window.viewer.scene.pickPosition(e.position); var ellipsoid = window.viewer.scene.globe.ellipsoid; var cartesian3 = new Cesium.Cartesian3( position.x, position.y, position.z ); var cartographic = ellipsoid.cartesianToCartographic(cartesian3); var lat = Cesium.Math.toDegrees(cartographic.latitude); var lng = Cesium.Math.toDegrees(cartographic.longitude); var alt = cartographic.height; // 依次是经度,纬度,高度 console.log(lng+‘-----‘+lat+‘--‘+alt); }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
标签:screen cti ips globe 地图 can div 获取 hand
原文地址:https://www.cnblogs.com/wanlige/p/13231267.html