Setting additional queryString on Tile Service

160
1
Jump to solution
12-17-2021 12:27 AM
NelsonC
New Contributor

My provider implemented additional authentication to Tile Services by adding an additional queryString parameter, such that each web request will need to be made with ?key=*******  (see example here). I am currently unable to use this service in the Android SDK, since I do not believe the Classes expose a way to modify the request url directly.

For example, for WmtsLayer I initialize it like this:

 

val wtmsBaseMap = WmtsLayer(
    "https://api.hkmapservice.gov.hk/ogc/wmts/basemap/WGS84/1.0.0/WMTSCapabilities.xml?key=***********",
    "MapAPI_HKBasemapService",
)

val basemap = Basemap(wtmsBaseMap)

 

This allows me to obtain the Capabilities configuration, but all the subsequent tile requests fail with 401 as they do not use the queryString ?key=****** .

WebTiledLayer is the exception as it seems to work as it directly takes the url input from the constructor. But obviously it suffers from many drawbacks such as lack of caching and configuration options. Ideally I would want other services to work as well.

Is there any way for me to implement this myself, or if not can support for custom queryStrings be added?

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

Hi @NelsonC,

You can call getCustomParameters() on your WmtsLayer, which gives you a modifiable Map of Strings that will allow you to set the "key" custom parameter. In other words, leave the URL without the ?key part and add a "key" to the Map.

Hope that helps!

View solution in original post

1 Reply
Nicholas-Furness
Esri Regular Contributor

Hi @NelsonC,

You can call getCustomParameters() on your WmtsLayer, which gives you a modifiable Map of Strings that will allow you to set the "key" custom parameter. In other words, leave the URL without the ?key part and add a "key" to the Map.

Hope that helps!