WebTiledLayer Template Modification

292
3
Jump to solution
01-28-2021 09:07 AM
NathanRaley
New Contributor III

I am attempting to use a WebTiledLayer and a query param to toggle labelling on and off based off the user's preferences, i.e. labels=0 or labels=1 to toggle them on and off.  The problem is, I apparently can't do this after the layer has been loaded.  Is there any way to get around this limitation, or what is the correct way if I needed to change that template on the fly?

Should I not be able to change that and trigger a reload on the layer in the map?

Thanks

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MatveiStefarov
Esri Contributor

I have logged an enhancement request on our internal tracker.  We will consider adding support for updating/refreshing WebTiledLayer in the future, now that there's a specific use-case for this extra functionality.  Thank you for the suggestion!

It wouldn't be quite as simple as changing URL on new requests -- there's also cache invalidation, canceling in-flight requests, and redrawing involved -- but it's absolutely doable.  This scenario just isn't implemented in Runtime yet.

Today, your best bet is to create different WebTiledLayers for different templates.

View solution in original post

3 Replies
MatveiStefarov
Esri Contributor

Hello Nathan!  It is true, the TemplateUri of a WebTiledLayer cannot be changed after the layer is loaded.

You may be able to intercept and rewrite network requests with the global ArcGISHttpClientHandler.HttpRequestBegin event, but I don't think it will solve your problem. Intercepting network requests will only affect new tile requests. It will not refresh any previously-requested, cached tiles.

Have you tried creating two WebTiledLayers, one with labels=0 and another with labels=1? Your application can toggle layer visibility so that only one is visible at a time. That's the best workaround that I can think of.

NathanRaley
New Contributor III

What is the reasoning behind not allowing the template to change?  It's merely changing the requests being sent is it not?  I'm not sure why it should be able to be updated and then trigger a refresh on the tiles, or at the very least make future requests honor the new template.

I was trying to avoid doubling up on all of our layers.

0 Kudos
MatveiStefarov
Esri Contributor

I have logged an enhancement request on our internal tracker.  We will consider adding support for updating/refreshing WebTiledLayer in the future, now that there's a specific use-case for this extra functionality.  Thank you for the suggestion!

It wouldn't be quite as simple as changing URL on new requests -- there's also cache invalidation, canceling in-flight requests, and redrawing involved -- but it's absolutely doable.  This scenario just isn't implemented in Runtime yet.

Today, your best bet is to create different WebTiledLayers for different templates.

View solution in original post