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