1

arcgis api for js can't connect to wmts sever with secret key

the wmts sever increas Adding Key Verification

before update:

 url:"http://t0.tianditu.gov.cn/img_c/wmts"

after update:

url:"http://t0.tianditu.gov.cn/img_c/wmts?tk=your secret key"

my secret key is:

8447f500c6f2b44fe8ddd3acccad4f38

so the new request is:

url:"http://t0.tianditu.gov.cn/img_c/wmts?tk=8447f500c6f2b44fe8ddd3acccad4f38"

my arcgis code is:

var layers=new WMTSLayer({
  url:"http://t0.tianditu.gov.cn/img_c/wmts?tk=8447f500c6f2b44fe8ddd3acccad4f38"
      });

but the chrome still request:

http://t0.tianditu.gov.cn/img_c/wmts/1.0.0/WMTSCapabilities.xml

without secret key request:

?tk=8447f500c6f2b44fe8ddd3acccad4f38

the right url should be:

http://t0.tianditu.gov.cn/img_c/wmts?tk=8447f500c6f2b44fe8ddd3acccad4f38/1.0.0/WMTSCapabilities.xml

how to write to let api request the url add secret key like:

http://t0.tianditu.gov.cn/img_c/wmts?tk=8447f500c6f2b44fe8ddd3acccad4f38/1.0.0/WMTSCapabilities.xml
Below the Radar
  • 7,321
  • 11
  • 63
  • 142
mikesui
  • 11
  • 2

1 Answers1

1

You should put your token inside the customParamaters like this:

var layers=new WMTSLayer({
  url:"http://t0.tianditu.gov.cn/img_c/wmts",
  customParameters: {
    tk: "8447f500c6f2b44fe8ddd3acccad4f38"
  }
});

For API v4.x:

For API v3.x:

customParametersObject

Use this to append custom parameters to all WMTS requests. The custom parameters are applied to GetCapabilities and GetTile. For example, if an access key is required, the key can be configured as a custom parameter.

Below the Radar
  • 7,321
  • 11
  • 63
  • 142