Cesium初始化


如果還不會配置和引入的話,可以去看一下我的這兩篇文章

https://www.cnblogs.com/reround/p/11943717.html
https://www.cnblogs.com/reround/p/12020661.html

1.給頁面添加一個div#cesiumContainer 

2.初始化方法

   

this.viewer = new this.Cesium.Viewer('cesiumContainer', {
        imageryProvider: new this.Cesium.UrlTemplateImageryProvider({
          url: this.sourceUrl +'/webearth/tiles/world/{z}/{x}/{reverseY}.jpg',  // sourceUrl 是配置的ip地址和端口 后面是路徑是后台提供的
          proxy: new this.Cesium.DefaultProxy('/proxy/')   //cesium的跨域
        }),
        baseLayerPicker: false,   //圖層選擇器
        animation: false,   //左下角儀表
        fullscreenButton: false,   //全屏按鈕
        geocoder: false,   //右上角查詢搜索
        infoBox: false,   //信息框
        homeButton: false,   //home按鈕
        sceneModePicker: true,  //3d 2d選擇器
        selectionIndicator: false,  //
        timeline: false,   //時間軸
        navigationHelpButton: false,  //右上角幫助按鈕
        contextOptions: {   //截圖需要的
          webgl:{
            alpha: true,
            depth:true,
            stencil:true,
            antialias:true,
            premultipliedAlpha:true,
            //通過canvas.toDataURL()實現截圖需要將該項設置為true
            preserveDrawingBuffer:true,
            failIfMajorPerformanceCaveat:true
          }
        }
      })

定義在init() 里后,記得調用

如果你需要哪些功能,可以把對應的代碼去掉,cesium默認是有的 

如果你加載的圖層是cesium的圖層 你得去cesium的官網注冊一個 ion token 不然有的圖層你是沒法使用的 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM