function getHeightByLngLat(viewer, lng, lat) {
var height = 0;
var cartographic = new Joint3d.Cartographic.fromDegrees(lng, lat);
if (!Joint3d.BaseLib.defined(cartographic)) {
return height;
}
try {
height = viewer.scene.sampleHeight(cartographic);//获取给定点的3DTiles高度
if (height == undefined || height < 0) {//没有3DTiles
height = viewer.scene.globe.getHeight(cartographic);//获给定点的地形高程
if (height == undefined || height < 0 ) {//没有地形
height = 0;
}
}
}
catch (err) {
height = viewer.scene.globe.getHeight(cartographic);//获给定点的地形高程
if (height == undefined || height < 0 ) {//没有地形
height = 0;
}
}
return height;
};