viewer.scene.mode = Cesium.SceneMode.SCENE2D;//平面场景
在这个平面场景中,下面的测距不能用,handlerDis.measureEvt.addEventListener(function(result)不触发,请问有什么办法吗?
function distanceHandler(viewer, Cesium, clampMode){
//初始化测量距离
handlerDis = new Cesium.MeasureHandler(viewer,Cesium.MeasureMode.Distance,clampMode);
//注册测距功能事件
handlerDis.measureEvt.addEventListener(function(result){
var dis = Number(result.distance);
var distance = dis > 1000 ? (dis/1000).toFixed(2) + 'km' : dis.toFixed(2) + 'm';
handlerDis.disLabel.text = '距离:' + distance;
});
handlerDis.activeEvt.addEventListener(function(isActive){
if(isActive == true){
viewer.enableCursorStyle = false;
viewer._element.style.cursor = '';
$('body').removeClass('measureCur').addClass('measureCur');
}
else{
viewer.enableCursorStyle = true;
$('body').removeClass('measureCur');
}
});
}