• 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
          })
        })
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    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
            }
        });
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
  • 相关阅读:
    Libgdx游戏开发(6)——游戏暂停
    Docker内时区查询和修改方法
    使用vite搭建vue3
    SAP MM的基础
    Java:搞清楚这三类Java面试问题,offer就稳了
    设计模式—结构型模式之代理模式
    【Rust】快速教程——从hola,mundo到所有权
    聊聊Spring扩展点BeanPostProcessor和BeanFactoryPostProcessor
    springboot配置过滤器和多个拦截器、执行顺序
    Kafka KRaft模式探索
  • 原文地址:https://blog.csdn.net/shanshanqwertyuiop/article/details/137833346