gis

arcgis js api4.7:加载天地图

2018-05-11  本文已影响4人  gis杭州

加载天地图、天地图注记、影像:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>天地图</title>
  <style>
    html, body, #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>
  <link rel="stylesheet" href="https://js.arcgis.com/4.7/esri/css/main.css">
  <script src="https://js.arcgis.com/4.7/"></script>
  <script>
    require([
      "esri/Map",
      "esri/views/MapView",
      "esri/layers/WebTileLayer",
      "dojo/domReady!"
    ], function(Map, MapView,WebTileLayer){
      var map = new Map({
        // basemap: "streets"
      });
      var view = new MapView({
        container: "viewDiv",
        map: map,
        zoom: 9,
        center: [120, 30]
      });
      var tdtMap_img = new WebTileLayer({//天地图影像
        urlTemplate: "http://{subDomain}.tianditu.com/DataServer?T=img_w&x={col}&y={row}&l={level}",
        subDomains: ["t0","t1","t2","t3","t4","t5","t6","t7"],
        copyright: "天地图影像"
      });
      var tdtMap = new WebTileLayer({//天地图
        urlTemplate: "http://{subDomain}.tianditu.com/DataServer?T=vec_w&x={col}&y={row}&l={level}",
        subDomains: ["t0","t1","t2","t3","t4","t5","t6","t7"],
        copyright: "天地图"
      })
      var tdtMap_anno = new WebTileLayer({//天地图注记
        urlTemplate: "http://{subDomain}.tianditu.com/DataServer?T=cva_w&x={col}&y={row}&l={level}",
        subDomains: ["t0","t1","t2","t3","t4","t5","t6","t7"],
        copyright: "天地图注记"
      })
      map.add(tdtMap);
      map.add(tdtMap_anno);
    });
  </script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
上一篇下一篇

猜你喜欢

热点阅读