Real-world maps
Besides the map of your scene, Worldprint can show a real place, or a picture you provide. These maps are made of tiles: small square images that a tile server (a web service that serves map pieces by zoom and position) sends as the player moves.
Pick a map in the Inspector
On a map object without a style (an empty Map View, not one made by Add Map to Scene), the Inspector shows an Online Tiles menu. Choose one and the fields below it are filled in:
Choice |
Notes |
|---|---|
OpenStreetMap |
No key. For light use only (see below). |
OpenTopoMap |
No key. Topographic look, no availability guarantee, and the service asks to be told of your use. |
MapTiler (your key) |
Needs a key from your own MapTiler account. Replace |
Thunderforest (your key) |
Needs a key from your own Thunderforest account. Replace |
Folder in StreamingAssets |
Your own tiles on disk (see below). |
Worldprint ships no key. The other fields are Tile Size, Tiles Max Zoom (the closest zoom the server has) and Attribution. Press Play to see the map.
Use a tile server from code
map.UseXyz("https://tile.openstreetmap.org/{z}/{x}/{y}.png", 256, "© OpenStreetMap contributors");
{z}, {x} and {y} are replaced by the zoom and the tile position. Any server that uses this pattern works.
An optional last argument is the closest zoom the server has (default 19).
Use a folder of tiles
Put the tiles in Assets/StreamingAssets/Tiles/, as {z}/{x}/{y}.png (a folder per zoom, then a folder per
x, then a {y}.png file), and pick Folder in StreamingAssets, or write:
map.UseXyz("Tiles/{z}/{x}/{y}.png");
The folder ships with the build, so the map works offline.
Show one picture
UseImage stretches one PNG or JPEG (a hand-drawn map, a screenshot) between two opposite corners. The corners can
be scene positions, for example the corners of your terrain:
map.UseImage("WorldMap.png", new Vector3(-500, 0, 500), new Vector3(500, 0, -500));
The path is relative to StreamingAssets. A texture of your project works too, readable or not:
public Texture2D worldMap;
...
map.UseImage(worldMap, new Vector3(-500, 0, 500), new Vector3(500, 0, -500));
Changes made to the texture afterwards are not shown: call UseImage again. Very large pictures are not cut into
pieces, so keep them moderate.
Credit and terms of use
The credit you give (Attribution) shows in a small box at the bottom-right of the map. Keep it: most servers require it.
Warning
Read the terms of the server before you ship.
OpenStreetMap’s own servers are for light use only: no heavy traffic, no bulk download. For a released game, use a provider with an account.
Worldprint keeps downloaded tiles on disk, in the player’s cache folder (
Application.temporaryCachePath), for as long as the server allows, and asks the server again after that. Up to 256 MB are kept; the oldest go first. Without a connection, the tiles seen before still show.Keys are yours. Do not publish them in a public repository.
Place things on a real-world map
On these maps a position is a longitude and a latitude, not a scene position:
var florence = MapCoordinate.LngLat(11.2558, 43.7696);
map.EaseTo(florence, zoom: 14);
map.AddPoint(florence, Color.red);
See Coordinates. A map shown with UseImage also accepts scene positions.