Since V7, World Map Strategy Kit can integrate with different tile servers to enable new Earth styles that provides progressive zoom detail. To enable this feature just enable the Tile system in the inspector.
Once you enable “Show Tiles” under Tile System section, the asset will automatically begin showing tiles based on current view and distance to Earth.
Options displayed in this section are:
Server: choose one of the provided tile servers. You can extend the list by editing the file WMSKTileServers.cs inside the Scripts folder.
Copyright notice: this is the copyright notice you should show in your applications according to the license you may have purchased from online map systems (see API Key below).
Currently the tile servers included are:
|OpenStreeMap||Normal / DE / Hiking
|Stamen||Terrain / Toner / Watercolor
|Carto||Light All / Dark All / No Labels / Only Labels / Dark mode
||Satellite / Satellite No Labels / Relief
|MapBox||Satellite / Terrain / Terrain (RGB-dem encoded) / Countries / Incidents / Streets / Traffic
||Topo / Streets / Satellite / National Geo Style
||Can connect to any tile server with customized URL and parameters
Transparent Tiles: when enabled, all tiles will use a transparent material which enables seeing through them the map texture revealing the background map texture.
Max Zoom Level: the maximum zoom level for which tiles will be downloaded. The usual max zoom level of tile system is between 15-20 (which can reach street level zoom).
Lines Max Zoom Level: map lines will be hidden beyond this zoom level.
Restrict To Area: only download tiles within a given area.
Tile Resolution: determines the maximum scaling when zooming in. A higher value will provide the sharpest resolution but also will lead to more tile downloads.
Max Concurrent Downloads: determines the maximum number of tile downloads at any given time. This value can be increased depending of the quality and bandwidth of your Internet connection.
Max Loads Per Frame: this is the maximum number of tiles showing up per frame. This option just refers to how many tiles will be activated per frame once they have been downloaded. When one tile is downloaded it’s activated, and it appears on the map with a fade animation. This parameter controls the maximum number of animations started per frame.
Preload Main Tiles: only show tiles when all tiles from first zoom level have been loaded. This avoids the initial tile download effect.
Show Console Errors: if enabled, any tile request or download error will be printed out to the console if running inside Unity Editor or to the player.log file if running in a build).
Enable Local Cache: stores downloaded tiles locally into your device. The local cache size defaults to 50 Mb. The cache will automatically remove older tiles. You may increase this value to allow offline tile browsing.
Cache Usage: press Recalculate to display current usage of the local cache space. Press Purge to to remove those files.
Note that you have also access to a tile API set of functions and properties which you can use to control and customize the tile system feature with scripting.
Downloading and embedding tiles with your application
It is possible to download and load map tiles from your application bundle directly. World Map Strategy Kit includes a Tile Downloader assistant that enables you to select a zoom level range and world area and fetch the tiles to a custom Resources folder inside your Unity application.
Each tile is a small PNG image file with name z_x_y.png referring to the zoom level and x/y tile coordinates. Tiles are stored in a subfolder with a number corresponding to the tile server enum. Please note that number of tiles grow exponentially with the zoom level. For a table of number of tiles per zoom level refer to https://wiki.openstreetmap.org/wiki/Tile_disk_usage
The new options are located in the Tile System section of WMSK’s inspector:
Resources Path: specify the root in the application project where the downloaded tiles will be stored. This path must be contained within the Assets folder at any level but must end with the “Resources” word.
Only Offline Tiles: if enabled only tiles available in the resource path will be used. If the user zooms or navigate to an area where no tiles are available, the Fallback texture will be used for those tiles.
Important: it’s recommended to set the Max Zoom Level setting to the higher zoom level of the downloaded tiles.
Click “Open Tiles Downloader” to open the downloader assistant:
The downloader assistant shows the following options:
Zoom Level Min / Max: the range of zoom levels to download.
Concurrent Downloads: maximum number of simultaneous downloads. If your Internet connection and tile server can afford it, you can increase this number to download more tiles per second.
World Area: choose between “Full World” or “Restricted”. The restricted mode will download tiles within a given rectangle defined by latitude/longitude. For convenience a list of countries are shown which you can select to quickly select their rect area in the world.
Tile Count: this is the number of tiles that will be downloaded according to the range of zoom levels and selected world area.
Estimated Size: click “Estimate” to download a sample of tiles and produce an estimation of storage size for all the tiles. This is a very rough number and the actual size may vary.
Downloaded Tiles: total number and size of currently downloaded tiles.
- Use a limited zoom level to download tiles (ie. 5-6). As number of tiles grow exponentially with the zoom level, it’s not practical to include higher zoom levels unless you restrict the area.
- The downloader can be stopped at any time. When you click “Start” it will not download/replace any previously downloaded tile, so work can continue.
- If “Only Offline Tiles” is not checked, then the Tile System will try to load the tile from the Resources path. If not found, it will search in the Local Cache (if cache is enabled). Finally it will try to download it from the remote tile server.
- If you just want to accelerate the load of the tiles in your application, you can download the tiles for only zoom level 5. Do NOT enable the “Only Offline Tiles” so the application will automatically download tiles for higher zoom levels.
- If you want to limit your application to a restricted set of tiles, then enable the “Only Offline Tiles” and make sure you download all the tiles using the Tiles Downloader. Remember that the Tiles Downloader assistant won’t remove any downloaded tile unless you click the “Delete” button. This behaviour allows you to combine different rectangle areas per different zoom levels.