Quick start
The example below, running in the Mappia calculator - click it to run it live. Full-size picture
- Run it
Click the picture: the map opens right here and runs the example. Nothing is saved, and nothing to install.
- Try it
- Zoom in on the topographic map: more detailed OpenTopoMap tiles load at each zoom level.
- Turn OpenTopoMap off with the eye button in the layer panel: the basemap shows underneath.
- Replace
urlwith another service’s ${z}/${x}/${y} address and run it again.
- Make it yours
Copy the query, change it - the key parameters are below - and run it again in the playground, or paste it into the Mappia editor to save it as your map.
Key parameters
| Parameter | Example | What it does |
|---|---|---|
source | xyz | Makes the layer fetch ready-made tiles, addressed by zoom, column and row, from url. |
url | https://a.tile.opentopomap.org/${z}/${x}/${y}.png | The tile address. ${z}, ${x} and ${y} are replaced by the zoom, column and row of each tile. |
name | opentopomap | A unique identifier for the layer: any text no other layer of the query uses. |
opacity | 0.9 | From 0 (invisible) to 1 (solid); lower it to see the layers underneath. |
visibility | true | Starts the layer turned on. The user can still switch it in the layer panel. |
Every parameter, with its type and default, is in the reference at the end of this page.
Complete example
The query 11 lines · runs as is
// XYZ layer: tiles addressed by zoom/column/row; ${z}, ${x} and ${y} are replaced per tile.
[
{
title: "OpenTopoMap",
name: "opentopomap",
source: "xyz",
url: "https://a.tile.opentopomap.org/${z}/${x}/${y}.png",
visibility: true,
opacity: 0.9,
},
];Customize it
Write the placeholders as ${z}, ${x}, ${y}
The dollar sign and the braces are both needed. Older examples wrote $z/$x/$y, which is not replaced, so every tile request fails. Put each placeholder where the service expects it - some services put the row before the column:
{
title: "Satellite imagery",
name: "esri_imagery",
source: "xyz",
url: "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/${z}/${y}/${x}",
visibility: true,
}
Which services work
Any service that serves square tiles in the usual web scheme - Web Mercator, row 0 at the top - the scheme of OpenStreetMap and most online basemaps. A TMS service that counts rows from the bottom shows its tiles in the wrong places.
Services that need a key
Put the key in url, as the service documents it. Anyone who opens the map can read the query and its key, so use a key restricted to your site. Check each service’s terms of use and attribution rules before publishing a map with it.
Use it offline
The tiles of an XYZ layer can be downloaded for use without a connection - see offline areas.
Related layers
To offer several basemaps the user can switch between, see the background map picker. For vector data (points, lines, polygons) rather than images, use a file layer.