ThinkGeo.com    |     Documentation    |     Premium Support

Online maps and tile cache

Hi,

  1. Like said before we use overlay.DrawingException now to draw custom exceptions but I guess that same (throwing any other that OperationCanceledException) applies to that also ?

  2. I also noticed that after exceptions are drawn and you set layers IsVisible to false and refresh the map empty tiles are stored to cache for those tiles which had exception drawn. I discovered this on our app with OgcApiFeatureLayer but can be reproduce also with that sample you gave earlier HandleException_04112025.zip. I just added button to UI with this kind of handler:

     private void ChangeVisibility(object sender, RoutedEventArgs e)
     {
         _wms.IsVisible = false;
         _ = MapView.RefreshAsync();
     }
    

Br, Simo

Hi Simo,

  1. Yep, that’s right.

  2. I see. It’s because _wms.IsVisible = false prevents _wms from being rendered, thus DrawingException will not be raised and our custom Exception will not be thrown. As a result, Overlay would think the tile is valid so just go ahead and cache it.

You can just set the overlay instead of the layer to InVisible, as following:

   private void ChangeVisibility(object sender, RoutedEventArgs e)
   {
       //_wms.IsVisible = false;
       staticOverlay.IsVisible = false;
       _ = MapView.RefreshAsync();
   }

Thanks,
Ben

Hi,

Will that 2. work differently on 14.3 ? We can have multiple OgcApiFeatureLayers with one overlayer and we would like to control visibility of each layer individually.

Br,Simo

Hi Simo,

  1. No more workaround is needed in v14.3. You don’t need to throw in the DrawingException handler anymore. Simply doing wms.IsVisible = false will not cache any illegal tiles—so you’re free to use it. We’ve updated the HandleException HowDoI sample for v14.3. Take a look here:
    https://gitlab.com/thinkgeo/public/thinkgeo-desktop-maps/-/blob/develop/samples/wpf/HowDoISample/Samples/Miscellaneous/HandleExceptions.xaml.cs

  2. Instead of putting multiple OgcApiFeatureLayer s into a single LayerOverlay , another option is using separate OgcApiFeaturesOverlay instances. Each overlay supports “progressive rendering”—for example, you can draw the first 500 of 1,000 features immediately, then load the rest in batches. It doesn’t mean this is always better than LayerOverlay, here are some quick pros and cons:

  • Memory footprint:
    One LayerOverlay with many layers uses less memory than several overlays.
    LayerOverlay with multiTile mode can draw the data by tiles.
  • Redraw behavior:
    Toggling visibility on a layer inside a LayerOverlay forces all its sibling layers to redraw. Hiding or showing an entire Overlay only affects that overlay.
  • Progressive loading:
    The WFS 2.0 / OGC API – Features spec supports progressive feature delivery, and OgcApiFeaturesOverlay can take full advantage of it by setting DrawingBulkCount to control batch size.
  • Here’s a sample that shows exactly how to set it up:
    samples/wpf/HowDoISample/Samples/MapOnlineData/OGCAPIFeatureServer.xaml.cs · develop

Thanks,
Ben

Hi,

Thanks, I think that we have now solved all issues related to cache.

I have still one more question. We would like to have possibility to download maps to cache before going to area without or with limited network connection. It means that user could select area and click a button and tiles would be downloaded to cache automatically (for next n. zoom levels)

Is there any support on ThinkGeo for this kind of functionality which could be used or what would be the best way to implement it ? It would be also nice if this could be done on the background without using the map visible to user.

Br,Simo

Hi Simo,

We do have all the pieces, but I don’t think there’s a straightforward way to accomplish this without writing some code / understanding the Matrix system. Let us think more about it and see if we can add some simple APIs to accomplish it in v14.3.

Thanks,
Ben

Hi,

Thanks, it would be great if you could have some builtin support for downloading tiles to cache for different kinds of online maps. Let me know if you came up with some solution.

Br,Simo

Hi Simo,

We’ve added a couple of new samples to HowDoI :

The first sample demonstrates how to pre-generate caches for a: TileOverlay :

It shows how to:

  1. Pre-generate cache tiles within a given extent and zoom range using a single line of code.
  2. Apply a different tile matrix set to a TileOverlay and generate the cache based on that matrix.

We also added a sample for generating tiles for an XyzLayer . It’s similar to the one above but specifically targets XYZ-based layers:

Thanks,
Ben

Hi,

Thanks, it looks good and this API is available on coming 14.3 release ?

Br, Simo

Yep. We are doing the final test / API reviews now and the release will be available next week.