//添加标记
function addMarker() {
list = [
{
lng: 112.987942,
ang: 28.189387,
text:'aaaa'
},
{
lng: 112.987942,
ang: 28.289387,
text:'bbbb'
}
];
drawMarker(list);
}
const drawMarker = (list = []) => {
list.map((i) => {
viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(
i.lng,
i.ang
),
billboard: {
image: `../images/location.png`,//图标地址
// horizontalOrigin: Cesium.HorizontalOrigin.LEFT,//原点位于对象的左侧。
verticalOrigin: Cesium.VerticalOrigin.TOP,//原点位于对象的顶部。
// disableDepthTestDistance: Number.POSITIVE_INFINITY,//禁用深度测试距离
pixelOffset: new Cesium.Cartesian2(-6, 10),//像素偏移
// scale: 0.8,//比例
},
label: {
text: i.text,
color: Cesium.Color.fromCssColorString("#fff"),
},
});
})
};
//清除所有的标记
const clearMarker=()=>{
viewer.entities.removeAll();
}
学习路之Cesium--固定位置增加标记功能、删除标记
于 2023-06-11 16:01:51 首次发布