Tiles Cache
RadMap allows you to cache the tile images downloaded by the map provider.
The tiles caching is disabled by default. To enable it, set the IsTileCachingEnabled
property of the map provider to true
. The default cache storage is the file system and the original location should look something like this: C:\Users\<username>\AppData\Local\TelerikMapCache\OpenStreetMapProvider
RadMap providers use the FileSystemCache
class to enable the tiles caching. Additionally, there are two more built-in caching implementations - MemoryCache
and IsolatedStorageCache
- which can be set via the CacheStorage
property of the provider.
FileSystemCache
FileSystemCache
saves the requested tiles to the file system. This type of cache allows you to define few settings like max size of the storage, an expiration date-time for the tiles and also the file system directory where the tiles are saved.
Example 1: Setting FileSystemCache and changing the default path
FileSystemCache
is the default storage object that is automatically created when the CacheStorage
property of the provider is not assigned. When the file system cache is atuomatically created its CachePath
is assigned to the ApplicationData folder on the OS: C:\Users\<username>\AppData\Local\TelerikMapCache\<providername>
.
MemoryCache
MemoryCache
saves each tile in a byte array stored in memory.
Example 2: Replacing the default FileSystemCache with MemoryCache
IsolatedStorageCache
IsolatedStorageCache
saves the requested tiles into the isolated storage.
Example 3: Replacing the default FileSystemCache with IsolatedStorageCache
Custom Cache Storage
Besides the built-in cache storages, a custom storage can be created by implementing the ICacheStorage
interface. This allows to introduce a saving mechanism different then the originally provided ones. The interface requests to implement Load
, LoadAsync
and Save
methods.
Example 4: Creating custom cache storage
Example 5: Using the custom cache storage
Request Cache Level
The RadMap
control uses the built-in .NET caching mechanism for downloading map tiles. The tiled providers expose a RequestCacheLevel
property which is used to control the current caching level. The default level is System.Net.Cache.RequestCacheLevel.CacheIfAvailable
.