1

js的arcgis api无法使用密钥连接到wmts服务器

wmts 服务器增加了添加密钥验证

更新前:</p>

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

更新后:

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

我的密钥是:

8447f500c6f2b44fe8ddd3acccad4f38

所以新的要求是:

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

我的 arcgis 代码是:

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

但铬仍然要求:

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

没有密钥请求:

?tk=8447f500c6f2b44fe8ddd3acccad4f38

正确的网址应该是:

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

如何编写让 api 请求 url 添加密钥,如:

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

1 回答 1

1

你应该把你的令牌放在customParamaters这样的里面:

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

对于 API v4.x:

对于 API v3.x

自定义参数对象

使用它来将自定义参数附加到所有 WMTS 请求。自定义参数应用于 GetCapabilities 和 GetTile。例如,如果需要访问密钥,则可以将密钥配置为自定义参数。

于 2019-02-18T16:39:24.583 回答