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://cdn.jsdelivr.net/npm/maptalks/dist/maptalks.css">
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/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=de0dc270a51aaca3dd4e64d4f8c81ff6';

      maptalks.SpatialReference.loadWMTS(url, function (err, conf) {
        if (err) {
          throw new Error(err);
        }
        var params = conf[0];
        params.urlTemplate += '&tk=de0dc270a51aaca3dd4e64d4f8c81ff6';
        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!