scene = viewer.scene;var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);handler.setInputAction(function(evt) { var scene = viewer.scene; if (scene.mode !== Cesium.SceneMode.MORPHING) { var pickedObject = scene.pick(evt.position); if (scene.pickPositionSupported && Cesium.defined(pickedObject)) { var cartesian = viewer.scene.pickPosition(evt.position); if (Cesium.defined(cartesian)) { var cartographic = Cesium.Cartographic.fromCartesian(cartesian); var lng = Cesium.Math.toDegrees(cartographic.longitude); var lat = Cesium.Math.toDegrees(cartographic.latitude); var height = cartographic.height;//模型高度 mapPosition={x:lng,y:lat,z:height}; console.log(mapPosition); } } }}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
原文地址:https://www.cnblogs.com/943711466qq/p/9497444.html
时间: 2024-10-08 13:38:44