【解决办法】1.贴地效果也是让图标锚点贴地,锚点通常是在图片中心,所以会一半地上一半地下
2. billboard贴地示范代码
var viewer = new Cesium.Viewer('cesiumContainer',{
//添加STK World Terrain地形服务
terrainProvider : new Cesium.CesiumTerrainProvider({
url : URL_CONFIG.STK,
requestWaterMask : true,
requestVertexNormals : true
}),
//添加BingMaps影像服务
imageryProvider : new Cesium.BingMapsImageryProvider({
url : '
https://dev.virtualearth.net',
mapStyle : Cesium.BingMapsStyle.AERIAL,
key : URL_CONFIG.BING_MAP_KEY
})
});
//设置相机视角
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(103.064734, 31.12816),
billboard :{
image : './images/省级.png',
heightReference:Cesium.HeightReference.CLAMP_TO_GROUND
}
});
viewer.scene.globe.depthTestAgainstTerrain = false;
viewer.scene.camera.setView({
destination : new Cesium.Cartesian3.fromDegrees(103.064734,31.12816,8870.867706),
orientation : {
heading : 0.34555839949062594,
pitch : -0.1422794351856307,
roll : 0.0009471063581933947
}
});
3.如果不想一半地上一半地下,有两种方式
(1) 就用绝对高度,但是点或者布告板得有高程信息
(2) 使用viewer.scene.globe.depthTestAgainstTerrain = false;,这样实体就不会被地形遮挡,会靠近地面,但也不是完全贴地