设置视角:
this.viewer.camera.setView({ destination: Cesium.Rectangle.fromDegrees( this.position.west, this.position.south, this.position.east, this.position.north ), orientation: { heading: Cesium.Math.toRadians(0), pitch: Cesium.Math.toRadians(-90), roll: Cesium.Math.toRadians(0) } })
entity添加广告牌:
let model = { id: 'model', position: Cesium.Cartesian3.fromDegrees(longitude, latitude), billboard: { image: this.boostImg, 40, height: 40 } } this.viewer.entities.add(model)
primitives添加广告牌
let billboards = viewer.scene.primitives.add(new Cesium.BillboardCollection()) billboards.add({ id: `billboard-${data[i].id}`, position: Cesium.Cartesian3.fromDegrees(position[0], position[1]), image: require('/assets/map/dot.png'), horizontalOrigin: Cesium.HorizontalOrigin.CENTER, verticalOrigin: Cesium.VerticalOrigin.CENTER, scaleByDistance: new Cesium.NearFarScalar(50000, 1, 6000000, 0.1), distanceDisplayCondition: new Cesium.DistanceDisplayCondition(50000, 6000000) })
移除添加的广告牌
if(billboards.length) { billboards.removeAll() } if(viewer.entities.getById(`model`)) { viewer.entities.remove({id: 'model'}) }