Turning off tile cache

1264
6
Jump to solution
02-08-2019 06:47 AM
MichalStolba
New Contributor II

Dear all,

I am implementing a custom tile layer using ServiceImageTiledLayer because of some custom tile parameters we need to take into account. The problem is that when I incorporate the new parameters into the tile URL in tileUrlCallback, the tiles are already cached and thus does not update (if I zoom in or pan to a new area, the tiles are loaded with the correct new parameters).

Is there a way to reload the whole layer? Or is there a way to disable the cache so that ServiceImageTiledLayer is requesting the tiles always again? I was thinking about setting the cache size to 0, but I cannot find how. I only found the "esri.mapping.cache.disk.size" of the Esri QLocation plugin, but I am not using the plugin, I am using the ArcGIS Runtime. Is there a way to set this (or similar) property?

Any help would be greatly appreciated,

best,

Michal

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

How often are you needing to do this? If it's multiple times per second, I'm not sure how to work around it. But if it is less frequent, you could wait and check the layer view state and draw state - the fact that it is done loading just means all resources have been fetched, but it doesn't necessarily mean anything has finished rendering. You can use draw status and layer view state for that:

arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_QMLSamples/Maps/DisplayDrawingStatus at master · Esri/a... 

arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_QMLSamples/Maps/DisplayLayerViewDrawStatus at master · ...  

View solution in original post

6 Replies
LucasDanzinger
Esri Frequent Contributor

Unfortunately, I don't believe there is any way for you to turn off the caching. Are you wanting no caching to ever happen, or just not between sessions?

MichalStolba
New Contributor II

Thank you. Maybe the question was not posed well. What I am working on is basically a dynamic tiled layer with additional parameters, that is, when the additional parameters are changed, I need to reload the layer. My idea was that if the cache was disabled the layer would request the tiles every time again.

So the most important question is, can I force a tiled layer to reload? From all resources I have seen it seems that the answer is no.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Once a Layer has reached the loaded state, it can't be reloaded. Rather, you will need to create a new instance. Please see the Loadable doc under "Retry loading" - Loadable pattern for asynchronous resources—ArcGIS Runtime SDK for Qt | ArcGIS for Developers  

"The main use case for this method is if the loadable failed to load previously, for example, due to network outage or service interruption. It is not meant to refresh the metadata for an already loaded resource which should instead be accomplished by creating a new instance of the loadable resource."

So maybe when you want to "reload", instead you could remove the existing layer and stick the code to recreate your custom layer in some factory method that keeps generating a new one.

0 Kudos
MichalStolba
New Contributor II

Hi Lucas,

thanks again for a quick reply. The approach you suggest is actually what I ended up using, but there is another problem. The load status of the layer changes to Loaded before the layer is fully displayed which results in the old layer first disappearing and then appearing again (with the new data) creating an undesirable flickering effect. The code I am using is functionally this:

newLayer.onLoadStatusChanged.connect(function() {
                    if(newLayer.loadStatus === Enums.LoadStatusLoaded){
                       map.operationalLayers.clear();
                    }

                });

map.operationalLayers.append(newLayer);

Do you have any idea if I am doing something wrong or is it expected behaviour?

Best,

Michal

0 Kudos
LucasDanzinger
Esri Frequent Contributor

How often are you needing to do this? If it's multiple times per second, I'm not sure how to work around it. But if it is less frequent, you could wait and check the layer view state and draw state - the fact that it is done loading just means all resources have been fetched, but it doesn't necessarily mean anything has finished rendering. You can use draw status and layer view state for that:

arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_QMLSamples/Maps/DisplayDrawingStatus at master · Esri/a... 

arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_QMLSamples/Maps/DisplayLayerViewDrawStatus at master · ...  

MichalStolba
New Contributor II

It's much less often so it should be doable. Your tip seems to be what I was looking for but I was not aware of the MapView draw status. Thanks for your help!

0 Kudos