3.3. Some example configurations

Following are some example configurations with increasing complexity.

Example 3.1. Minimal configuration:

The absolute minimum for a GoogleMaps viewer without any caching:

Provider = GoogleMaps
Note that this uses the default URL and will fetch all visible tiles from the Google servers upon each paint event!


Example 3.2. Memory only caching:

A simple configuration for a GoogleMaps viewer with only memory caching:

CacheMemory.Provider = GoogleMaps
CacheMemory.SizeLimit = 64
GoogleMaps.URL = https://mt0.google.com/vt?lyrs=s&scale=${MapTile.Scale}&z=${MapTile.Zoom}&x=${MapTile.X}&y=${MapTile.Y}&hl=loc
Provider = CacheMemory
Note that this adapts the URL to use the satellite tiles and will cache the most recently used 64 tiles in memory.


Example 3.3. Combined memory and file caching:

A chained configuration for a GoogleMaps viewer with memory and file caching:

CacheFile.Directory = ${DYN_FILEDIR}/cache/default
CacheFile.Provider = GoogleMaps
CacheFile.MaxAge = 10-00:00:00.000
CacheMemory.MaxAge = 10-00:00:00.000
CacheMemory.Provider = CacheFile
CacheMemory.SizeLimit = 128
Provider = CacheMemory
Note that this will store all downloaded tiles in the directory cache/default below the directory that contains the configuration file itself. Note also that this will automatically re-fetch tiles which are older than 10 days since they were downloaded from GoogleMaps. The maximum age on the memory cache is specified to ensure that long running applications will also periodically re-check tiles that are already cached in memory.


Example 3.4. Single setup:

A chained configuration for a GoogleMaps viewer with memory and file caching, but this time configured as a single named setup:

SetupName = GoogleMaps-default
SetupNames = GoogleMaps-default
Setups.GoogleMaps-default.CacheFile.Directory = ${DYN_FILEDIR}/cache/default
Setups.GoogleMaps-default.CacheFile.Provider = GoogleMaps
Setups.GoogleMaps-default.CacheMemory.Provider = CacheFile
Setups.GoogleMaps-default.CacheMemory.SizeLimit = 128
Setups.GoogleMaps-default.Provider = CacheMemory
Note that this is functionally equivalent to the previous example.


Example 3.5. Multiple setups:

Two chained configurations for a GoogleMaps viewer with memory and file caching, with different URLs and thus different map styles:

Setting.TileCache.Directory = ${DYN_FILEDIR}/cache
SetupName = GoogleMaps-default
SetupNames = GoogleMaps-default,GoogleMaps-Satellite
Setups.GoogleMaps-default.CacheFile.Directory = ${Setting.TileCache.Directory}/default
Setups.GoogleMaps-default.CacheFile.Provider = GoogleMaps
Setups.GoogleMaps-default.CacheMemory.Provider = CacheFile
Setups.GoogleMaps-default.CacheMemory.SizeLimit = 128
Setups.GoogleMaps-default.Provider = CacheMemory
Setups.GoogleMaps-Satellite.CacheFile.Directory = ${Setting.TileCache.Directory}/satellite
Setups.GoogleMaps-Satellite.CacheFile.Provider = GoogleMaps
Setups.GoogleMaps-Satellite.CacheMemory.Provider = CacheFile
Setups.GoogleMaps-Satellite.CacheMemory.SizeLimit = 128
Setups.GoogleMaps-Satellite.GoogleMaps.URL = https://mt0.google.com/vt?lyrs=s&scale=${MapTile.Scale}&z=${MapTile.Zoom}&x=${MapTile.X}&y=${MapTile.Y}&hl=loc
Setups.GoogleMaps-Satellite.Provider = CacheMemory
Note that this now enables the toolbar button to switch between setups.


Example 3.6. Offline setups:

Two chained configurations for a GoogleMaps viewer with memory and file caching, but one of them being a pure offline viewer:

Setting.TileGrid.Visible = true
SetupName = GoogleMaps-offline
SetupNames = GoogleMaps-offline,GoogleMaps-Satellite
Setups.GoogleMaps-offline.CacheFile.Directory = ${DYN_FILEDIR}/cache/satellite
Setups.GoogleMaps-offline.CacheFile.Provider = Offline
Setups.GoogleMaps-offline.CacheMemory.Provider = CacheFile
Setups.GoogleMaps-offline.CacheMemory.SizeLimit = 128
Setups.GoogleMaps-offline.Offline.MaxScale = 1
Setups.GoogleMaps-offline.Offline.MinScale = 1
Setups.GoogleMaps-offline.Provider = CacheMemory
Setups.GoogleMaps-Satellite.CacheFile.Directory = ${DYN_FILEDIR}/cache/satellite
Setups.GoogleMaps-Satellite.CacheFile.Provider = GoogleMaps
Setups.GoogleMaps-Satellite.CacheMemory.Provider = CacheFile
Setups.GoogleMaps-Satellite.CacheMemory.SizeLimit = 128
Setups.GoogleMaps-Satellite.GoogleMaps.URL = https://mt0.google.com/vt?lyrs=s&scale=${MapTile.Scale}&z=${MapTile.Zoom}&x=${MapTile.X}&y=${MapTile.Y}&hl=loc
Setups.GoogleMaps-Satellite.Provider = CacheMemory
Note that this allows to switch between online and offline mode. While the offline setup is active, it is guaranteed that no network requests will be made for any missing tiles: these will simply be displayed as dark gray squares (the default offline background color). Note also, that both setups make use of the same cache directory, thus reusing the tiles. For better orientation in areas with missing tiles, the tile grid is set to visible, thus showing the tile coordinates.