AnsweredAssumed Answered

TypeError: c is undefined

Question asked by feipu2211 on Jul 19, 2017
Latest reply on Jul 19, 2017 by feipu2211

       Thanks esri for publishing arcgis api for javascript v4.4, which supports wmts. But there are something wrong, when I try to using wmts services that are not privided by Global Imagery Browse Services (GIBS).

     The wmts url is:http://t6.tianditu.com/img_w/wmts ,while the site for this wmts services is :http://www.tianditu.com/service/info.html?sid=1061&type=info.

     Here is my code below:

 

 

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"></meta>
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"></meta>

 

 <link rel="stylesheet" href="https://js.arcgis.com/4.4/esri/css/main.css"/>  
  <title>TDT</title>

 

  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 95%; // allow space for sublayer switcher
      width: 100%;
    }

 

  </style>

 

 
</head>
<body>
 
  <div id="viewDiv"></div>
<script src="https://js.arcgis.com/4.4/"></script>

 

<!--   <script src="js/dojoExtend/WMTSLayer.js"></script> -->
<!-- <script src="js/dojoExtend/tdtWMTS.js"></script> -->
<script >

/**
 *
 */
    
        
      require([
          "esri/config",
        "esri/Map",
        "esri/geometry/Extent",
        "esri/views/MapView",
        "esri/layers/WMTSLayer",
        "dojo/domReady!"
      ], function(
        esriConfig,
        Map,
        Extent,
        MapView,
        WMTSLayer
      ) {
          esriConfig.request.corsEnabledServers.push("http://t6.tianditu.com");
          
          var tileExtent=new Extent({
            xmin: 120.64950513012732,
            ymin: 28.727049272378594,
            xmax: 121.86112667429612,
            ymax: 29.297168129375535,
            spatialReference: {
              wkid: 4490
            }
        });  
          var tdtFullExtent=new Extent({
            xmin: -180,
            ymin: -90,
            xmax: 180,
            ymax: 90,
            spatialReference: {
              wkid: 4490
            }
          });
      
          
                  
        
        var tdtWMTSLayer=new WMTSLayer({
            //Currently active sublayer. Defaults to the first sublayer in sublayers
            //activeLayer:"",
            //Use this to append different custom parameters to the WMTS tile requests. The custom layer parameters are applied to GetTile.
            //customLayerParameters:{},
            //Use this to append custom parameters to all WMTS requests
            
            //RESTful | KVP
            serviceMode:"KVP",
            //A collection of WMTSSublayer objects.            
            //The URL for the GetCapabilities is created based on the url and serviceMode properties.
            url:"http://t6.tianditu.com/img_w/wmts",
            version:"1.0.0"
            
        });
        
      var map=new Map({
          layers:[tdtWMTSLayer]
      });
      
      var view=new MapView({
          container:"viewDiv",
          map:map
      });
      
      view.then(function(){
          view.extent = tileExtent;
          var layerList = new LayerList({
              view: view
            });
          view.ui.add(layerList, "bottom-left");
      });
      
    });

</script>
 
</body>
</html>

Outcomes