1、查找entity:
let model = viewer.entities.getById("cc_model1");
2、删除entity:
viewer.entities.remove(this.bq);
3、给entity加个高亮的轮廓线:
model.model.silhouetteColor = new SceneGIS.Color.fromCssColorString(
"#28FF28"
);
model.model.silhouetteSize = 5;
4、相机飞过去:
viewer.camera.flyTo({
destination: new SceneGIS.Cartesian3(
-2598195.4354866184,
4752152.151171375,
3357273.565115823
),
orientation: {
heading: 1.926048318780058,
pitch: -0.34954160742460694,
roll: 6.283185264841394
}
});
5、查找一系列的entity,然后一起删除:
let ahwArray = [];
viewer.entities.values.forEach(entity => {
if (entity.id.indexOf("cc") > -1) {
ahwArray.push(entity);
}
});
ahwArray.forEach(ele => {
viewer.entities.remove(ele);
});
7、获取当前相机的位置和角度以及点击的位置的经纬度和高程:
this.handler = new SceneGIS.ScreenSpaceEventHandler(viewer.scene.canvas);
this.handler.setInputAction(function (movement) {
//相机位置
console.log("destination", viewer.scene.camera.position);
var head = viewer.scene.camera.heading;
var pitch = viewer.scene.camera.pitch;
var roll = viewer.scene.camera.roll;
var orientation = { heading: head, pitch: pitch, roll: roll };
//相机角度
console.log("orientation", orientation);
let cartesian = viewer.scene.pickPosition(movement.position);
// 是否获取到空间坐标
if (SceneGIS.defined(cartesian)) {
// // 空间坐标转世界坐标(弧度)
let cartographic = SceneGIS.Cartographic.fromCartesian(cartesian);
// 弧度转为角度(经纬度)
let lon = SceneGIS.Math.toDegrees(cartographic.longitude);
let lat = SceneGIS.Math.toDegrees(cartographic.latitude);
//模型高度
let height = cartographic.height;
console.log('经纬度', { x: lon, y: lat })
}
}, SceneGIS.ScreenSpaceEventType.LEFT_CLICK);