cesium切换图层及初始时定位至中国

/** 中国坐标 */
getChinaPostion() {
  return Cartesian3.fromDegrees(116.435314, 40.960521, 10000000.0);
},
/**
 *  初始定位中国
 * */
flytochina() {
  viewer.camera.flyTo({
    destination: this.getChinaPostion(),
    duration: 8
  });
},
/**
 * 切换地图
 */
changeBaseMap(type) {
  viewer.imageryLayers.removeAll();
  switch (type) {
    //天地图
    case "tdt":
      viewer.imageryLayers.addImageryProvider(
        new WebMapTileServiceImageryProvider({
          url:
            "https://t0.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=93d1fdef41f93d2211deed6d22780c48",
          layer: "tdtBasicLayer",
          style: "default",
          format: "image/jpeg",
          tileMatrixSetID: "GoogleMapsCompatible",
          show: false,
          maximumLevel: 16
        })
      );
      break;
    //天地图矢量
    case "tdtsl":
      viewer.imageryLayers.addImageryProvider(
        new WebMapTileServiceImageryProvider({
          url:
            "https://t0.tianditu.com/vec_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=vec&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=93d1fdef41f93d2211deed6d22780c48",
          layer: "tdtVecBasicLayer",
          style: "default",
          format: "image/jpeg",
          tileMatrixSetID: "GoogleMapsCompatible",
          show: false
        })
      );
      break;
    //谷歌影像
    case "gg":
      var url =
        "https://mt1.google.cn/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}&s=Gali";
      viewer.imageryLayers.addImageryProvider(
        new UrlTemplateImageryProvider({ url: url })
      );
      break;
    case "arcgis":
      viewer.imageryLayers.addImageryProvider(
        new ArcGisMapServerImageryProvider({
          url:
            "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
          enablePickFeatures: false
        })
      );
      break;
    //必应
    case "bing":
      viewer.imageryLayers.addImageryProvider(
        new BingMapsImageryProvider({
          url: "https://dev.virtualearth.net",
          key: "get-yours-at-https://www.bingmapsportal.com/",
          mapStyle: BingMapsStyle.AERIAL
        })
      );
      break;
    case "dark":
      viewer.imageryLayers.addImageryProvider(
        new createTileMapServiceImageryProvider({
          url: "https://cesiumjs.org/blackmarble",
          credit: "Black Marble imagery courtesy NASA Earth Observatory",
          flipXY: true // Only old gdal2tile.py generated tilesets need this flag.
        })
      );
      break;
  }

  //全球影像中文注记服务
  viewer.imageryLayers.addImageryProvider(
    new WebMapTileServiceImageryProvider({
      url:
        "https://t0.tianditu.com/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default.jpg&tk=93d1fdef41f93d2211deed6d22780c48",
      layer: "tdtAnnoLayer",
      style: "default",
      format: "image/jpeg",
      tileMatrixSetID: "GoogleMapsCompatible",
      show: false
    })
  );
  //全球矢量中文标注服务
  viewer.imageryLayers.addImageryProvider(
    new WebMapTileServiceImageryProvider({
      url:
        "https://t0.tianditu.com/cva_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cva&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default.jpg&tk=93d1fdef41f93d2211deed6d22780c48",
      layer: "tdtAnnoLayer",
      style: "default",
      format: "image/jpeg",
      tileMatrixSetID: "GoogleMapsCompatible"
    })
  );
}

 

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值