Force a layer to refresh after changing the RequestTileUri

I have one map with one layer and I set the RequestTileUri callback so I can provide the requested tiles when needed.
I have multiple tile providers, so when I use the map with one provider and then change to a new provider, I would like to force the layer to refresh, so it would fetch and draw the visible tiles again. This would then let me return tiles from the newly selected provider and the map would render that.

I can make the provider change and then zoom out and in (after disabling tile caching for the layer) and it will refresh, due to the zoom, and I can provide the new tiles and it will take effect. I would like to do this without having to zoom out and in, but through a call like
imageryLayer.Refresh()

5 Replies 1 reply marked as answer

SS Sridevi Sivakumar Syncfusion Team January 13, 2021 01:53 PM UTC

Hi Thomas,

Greetings from Syncfusion.

We have analysed your requirement, currently, we don't have direct support like ImageryLayer.Refresh() to achieve your requirement.

A map will get refresh while changing the GeoCoordinates. This GeoCoordinate contains the current state of Maps center point. To get refresh the tiles, you can change GeoCoordinates with some decimal fraction value like GeoCoordinates+0.001 again subtract this value from GeoCoordinates. This change will not affect visually and tiles will be refreshed with new providers.

Please try this workaround and let us know whether this approach resolved your requirement or not.

Regards,
Sridevi S.
 


Marked as answer

TH Thomas January 13, 2021 02:20 PM UTC

Thanks for the reply.
That sounds like an acceptable workaround. I assume I could change with any infinitely small non zero value.
Might want to try setting the same value again, as well, since you might not check for that before executing the underlying code?


ET Eswaran Thirugnanasambandam Syncfusion Team January 15, 2021 01:39 AM UTC

Hi Thomas, 
 
Thanks for your update. 
 
We tried the suggested workaround with a simple sample and based on the zoom level the map will refresh only when providing the geo coordinate value out of the view. So, changing the GeoCoordinates with some decimal fraction value like GeoCoordinates+0.001 will not be a generic solution and it will work only when giving the geo coordinate value out of the view. 
 
Your requirement can also be achieved by changing the zoom level property. When changing the zoom level, the tiles will be refreshed with new providers.  
 
To achieve your requirement, we have prepared a sample, in which we have decrement and incremented the zoom level for refreshing the map when the new provider is set.  The sample link is provided below. 
 
 
 
Please check the above sample and let us know whether your requirement is achieved in the provide sample.  
 
Regards, 
Eswaran. 



TH Thomas January 15, 2021 01:34 PM UTC

Thanks for the time you spent on testing this out. Impressive support.
The solution does seem to have issues, though.
Testing on android simulator here.

Changing map providers causes the center, and the zoom level, to sometimes shift.
Try zooming into some location and then change providers.
I generally see the center shift to 0,0 and often see the zoom level change as well, so it zooms out.

This seems to happen slightly more often when changing to bing than to osm.


RS Ramya Soundar Rajan Syncfusion Team January 18, 2021 12:23 PM UTC

 
We have modified the sample to maintain the zoom level and center point when the changing the map providers. Please refer the sample from the below location. 
 
Code snippet: 
 
[C#] 
 
        private void ImageryLayer_GeoCoordinateChanged(object sender, GeoCoordinateChangedEventArgs e) 
        { 
            mapCenterPoint = e.Center; 
        } 
 
        private void ImageryLayer_ZoomLevelChanging(object sender, ZoomLevelChangingEventArgs e) 
        { 
           mapZoomLevel= e.CurrentLevel; 
        } 
 
    
 
mapZoomLevel = sfmap.ZoomLevel; 
                imageryLayer.GeoCoordinates = new Point(mapCenterPoint.Y, mapCenterPoint.X);  
 
 
 
Please let us know, if you have any concerns. 
 
Regards, 
Ramya S 


Loader.
Up arrow icon