Cesium之home键开关及相机位置设置
显隐控制
设置代码中的homeButton
var TDT_IMG_C = "https://{s}.tianditu.gov.cn/img_c/wmts?service=wmts&request=GetTile&version=1.0.0" + "&LAYER=img&tileMatrixSet=c&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}" + "&style=default&format=tiles&tk=fa7ec9766b2c00747e3dd60ab3d05892";
var viewer = new Cesium.Viewer('map', {
baseLayerPicker: false, // 影像切换
animation: false, //是否显示动画控件
timeline: false, //是否显示时间线控件
infoBox: false, //是否显示点击要素之后显示的信息
geocoder: false, //是否显示地名查找控件
navigationHelpButton: false, //是否显示帮助信息控件
homeButton:true,//控制home键显隐
imageryProvider: new Cesium.WebMapTileServiceImageryProvider({
url: TDT_IMG_C,
layer: "tdtImg_c",
style: "default",
format: "tiles",
tileMatrixSetID: "c",
subdomains: ["t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7"],
tilingScheme: new Cesium.GeographicTilingScheme(),
tileMatrixLabels: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"],
maximumLevel: 50,
show: false
})
})
home键相机位置控制
// 创建 Cesium Viewer
var viewer = new Cesium.Viewer('cesiumContainer');
// 设置 home 键
viewer.homeButton.viewModel.command = function() {
// 设置相机位置
viewer.camera.setView({
destination: Cesium.Cartesian3.fromDegrees(120.678594, 24.803711, 1000),
orientation: {
heading: Cesium.Math.toRadians(0),
pitch: Cesium.Math.toRadians(-30),
roll: 0.0
}
});
};
原文地址:https://blog.csdn.net/shanshanqwertyuiop/article/details/137833346
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!