You have successfully installed MapTiler Server (on Linux, Mac, or Windows) and filled it with initial data. Now you want to create and serve your own beautiful maps. In this article, we will show you how to do it.
Map
As a map in the MapTiler ecosystem, we understand a set of style.json, its referenced tiles sources, and assets like icons and fonts used in this style. MapTiler Server loads maps from $workingDirectory/maps
. Each subdirectory here is considered as a map and will be listed on your server (e.g. $workingDirectory/maps/maptiler-streets/style.json
[1]).
Such a map directory must contain style.json and can contain icons used in a map in form of sprite (sprite.json
, sprite.png
, sprite@2x.json
, sprite@2x.png
).
Fonts are shared for all maps and are placed in $workingDirectory/fonts
. You can learn how to structure font files in this directory from the MapTiler Server data starter pack. Uploading this package is also the easiest way how to load your server with commonly used fonts. See how to upload it to server.
Currently only tiles in Mercator projection can be referenced in map hosted by MapTiler Server.
Style.json
Is a core map file that defines what data are drawn and its visual appearance.
Already mentioned data starter pack contains ready-to-use map styles prepared by our team that covers most of the use-cases and perfectly fits the MapTiler Data. You can create your custom style by writing it by hand or you can use tools available in MapTiler Cloud. If you have vector tiles in openmaptiles schema, you can get styles from cloud with following steps:
-
Sign in to your MapTiler Cloud account.
-
Choose one from available standard maps.
-
You can optionally customize it.
-
Open the
style.json
URL of desired map and save it. -
You have to fix references to resources in the saved
style.json
as will be described later.
Referencing locally served resources in your style.json
MapTiler Server supports special syntax for referencing local resources in your style.json
.
If you use value "#"
for property "glyphs"
, all requested font files will be served from directory ${workingDirectory}/fonts/
.
If you use value "#"
for property "sprite"
, all sprite files (sprite.json, sprite.png, sprite@2x.json, sprite@2x.png) will be served from directory ${workingDirectory}/maps/yoursMapId/
.
If you would like to refer tiles served by your MapTiler Server, use value #${tilesId}
in property "url"
of the source object e.g.:
"sources": { "openmaptiles": { "type": "vector", "url": "#maptiler-osm" } },
Values not starting with the "#"
prefix are considered as external references. This can lead to slower tile rasterization due to used network requests instead of direct file read.
Referencing MapTiler Cloud resources in MapTiler Server is not allowed and will not work.
Upload to server
Compress your style.json
and sprites
into a zip archive. Such a zip can be easily uploaded via servers upload interface.
-
MapTiler Server working directory can be specified during installation (Windows) / servicification (Linux) or as a CLI parameter <code>--workDir during on server run. In this directory is created server configuration config.json and it is a place for map data you want to serve.
Comments
0 comments
Please sign in to leave a comment.