cesium初始化

cesium初始化


引入地形

	Cesium.Ion.defaultAccessToken = 'cesium官网申请的token'
	
	// cesium原生 生成地形
    let terrainProvider = Cesium.createWorldTerrain({
        requestWaterMask: false, // 否需要请求额外的水
        requestVertexNormals: false // 光数据
    })
    // 创建map配置项
    const mapOptions = {
        homeButton: false, //是否显示主页按钮
        sceneModePicker: false, //是否显示场景按钮
        baseLayerPicker: false, //是否显示图层选择控件
        navigationHelpButton: false, //导航帮助按钮
        selectionIndicator: false, //鼠标选择指示器
        infoBox: false, //信息提示框
        animation: false, //是否创建动画小器件,左下角仪表
        timeline: false, //是否显示时间线控件
        geocoder: false, //是否显示地名查找控件
        fullscreenButton: true, //是否全屏按钮
        shouldAnimate: false, 
        destination: {
            x: 110.220501,
            y: 24.387122,
            z: 350,
        },
        orientation: [0, -90, 0],
        infoBox: false, // If set to false, the InfoBox widget will not be created.
        terrainProvider, // 在viewer配置项中添加地形数据
    }
    const viewer = new Cesium.Viewer('cesiumContainer', mapOptions);
    
    viewer._cesiumWidget._creditContainer.style.display = "none" // 去除版权信息
	viewer.scene.screenSpaceCameraController.minimumZoomDistance = 10 // 距离地形的距离
	viewer.scene.globe.depthTestAgainstTerrain = true // false 关闭/打开地形遮挡
	
	
    // viewer.imageryLayers.remove(viewer.imageryLayers.get(0)); // 删除默认的影像图层
    
    viewer.scene.fxaa = false;//改善实体图片清晰度,去除图片锯齿
    viewer.scene.postProcessStages.fxaa.enabled = true;去锯齿 使文字清晰
    if (Cesium.FeatureDetection.supportsImageRenderingPixelated()) {
      // 判断是否支持图像渲染像素化处理
      viewer.resolutionScale = window.devicePixelRatio;
    }

    // //加载本地地图
    // this.loadJPGMercator(viewer, 15);
    // //加载本地地形
    // this.loadLocalTerrain(viewer)

   // viewer.extend(Cesium.viewerCesiumInspectorMixin)  // 调试器 Cesium的Inspector面板可以显示Primitive的坐标轴、边界球等信息,还可以显示网格坐标系信息
    // viewer.extend(Cesium.viewerCesium3DTilesInspectorMixin); // 3dtiles插件 可以查看模型信息
    
    //设置指北针
    var options = {};
    // 用于在使用重置导航重置地图视图时设置默认视图控制。接受的值是Cesium.Cartographic 和 Cesium.Rectangle.
    options.defaultResetView = Cesium.Cartographic.fromDegrees(
      homePosition.lon,
      homePosition.lat,
      homePosition.height
    );
    // 用于启用或禁用罗盘。true是启用罗盘,false是禁用罗盘。默认值为true。如果将选项设置为false,则罗盘将不会添加到地图中。
    options.enableCompass = true;
    // 用于启用或禁用缩放控件。true是启用,false是禁用。默认值为true。如果将选项设置为false,则缩放控件将不会添加到地图中。
    options.enableZoomControls = false;
    // 用于启用或禁用距离图例。true是启用,false是禁用。默认值为true。如果将选项设置为false,距离图例将不会添加到地图中。
    options.enableDistanceLegend = false;
    // 用于启用或禁用指南针外环。true是启用,false是禁用。默认值为true。如果将选项设置为false,则该环将可见但无效。
    options.enableCompassOuterRing = true;
    // 利用插件
    CesiumNavigation(viewer, options);

	// 若使用高程数据,则需要配合图层一起使用
	 let terrainProvider = new Cesium.CesiumTerrainProvider({
       url: 'http://localhost:9003/terrain/BOXJg9Eg'
    });
    
    // 谷歌影像地址
	 let imageryProvider = new Cesium.UrlTemplateImageryProvider({
        url: "https://mt1.google.cn/vt/lyrs=s&x={x}&y={y}&z={z}"
    })
    
    const viewer = new Cesium.Viewer('cesiumContainer', {
        infoBox: false, // If set to false, the InfoBox widget will not be created.
        terrainProvider,
        imageryProvider
    });

高程数据在https://www.gscloud.cn/#下载后,通过cesiumlab进行切片(三角算法使用ctb,存储类型散列),切片后用cesiumlab分发服务本地部署即可

其他影像地址

  1. arcgis街道图
    https://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}

  2. 灰度图
    https://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetGray/MapServer/tile/{z}/{y}/{x}

  3. 深蓝夜色
    https://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}

  4. 谷歌map( lys参数可选值包括:h(街道图)、m(街道图)、p(街道图)、r(街道图)、s(影像无注记)、y(影像含注记)、t(地形图) )
    https://www.google.cn/maps/vt?lyrs=m@189&gl=cn&x={x}&y={y}&z={z}

  5. 卫星图
    https://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}(或者http://mt1.google.cn/vt/lyrs=s&x={x}&y={y}&z={z}

  6. Amap(高德地图 | z>=3才有数据)
    https://webrd01.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}

  7. 影像图
    https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}

  8. OSM街道图
    https://c.tile.openstreetmap.org/{z}/{x}/{y}.png
    https://tile-b.openstreetmap.fr/hot/{z}/{x}/{y}.png

  9. Mapbox
    https://b.tiles.mapbox.com/v3/osmbuildings.kbpalbpk/{z}/{x}/{y}.png

  10. 黑色底图
    https://a.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png

  11. MapBox卫星图(需要token)
    https://a.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=

  12. MapBox街道图(需要token)
    https://a.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.png?access_token=

  13. MapBox黑色带区块(需要token)
    https://a.tiles.mapbox.com/v4/mapbox.dark/{z}/{x}/{y}.png?access_token=

  14. 天地图(http://lbs.tianditu.gov.cn/server/MapService.html)影像图(z>=1)
    https://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=

  15. 天地图(http://lbs.tianditu.gov.cn/server/MapService.html)底图矢图(z>=1)
    https://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=9a516b0f2a8179bb68f73172cff4bd22

  16. 腾讯
    https://rt3.map.gtimg.com/tile?z={z}&x={x}&y={reverseY}&styleid=4&version=297

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Raccom

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值