Add a WMTS TileLayer
index.html
<!DOCTYPE html>
<html>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>TileLayer and Geo-Projections - Add a WMTS TileLayer</title>
  <style type="text/css">
    html,body{margin:0px;height:100%;width:100%}
    .container{width:100%;height:100%}
  </style>
  <link rel="stylesheet" href="https://unpkg.com/maptalks/dist/maptalks.css">
  <script type="text/javascript" src="https://unpkg.com/maptalks/dist/maptalks.min.js"></script>
  <body>

    <div id="map" class="container"></div>

    <script>
      var url = 'https://t0.tianditu.gov.cn/vec_c/wmts?request=GetCapabilities&service=wmts&tk=6901643c38b65f1f9770196343cf72b2';

      maptalks.SpatialReference.loadWMTS(url, function (err, conf) {
        if (err) {
          throw new Error(err);
        }
        var params = conf[0];
        params.urlTemplate += '&tk=6901643c38b65f1f9770196343cf72b2';
        var spatialReference = params.spatialReference;
        var tileLayer = new maptalks.TileLayer('tilelayer', params);
        var spatialReference = params.spatialReference;

        var map = new maptalks.Map('map', {
          center: [114.3404041441181, 30.548730054693106],
          zoom: 10,
          spatialReference : spatialReference,
          baseLayer: tileLayer
        });
      });


    </script>
  </body>
</html>
Copied!