This article shows how to set up MapTiler Server to load spatial data from your PostgreSQL database, serve them as map tiles, and how to integrate these tiles into your map.
Applications for this functionality include the ability to serve real-time data or data which is updated frequently, as vector tiles on top of a customizable base map.
a running PostgreSQL database with preinstalled PostGIS extension that is populated with some spatial data
installed MapTiler Server instance
optional: basic maps served from MapTiler Server instance which you can get from our data starter pack
Vector tiles schema
A vector tiles schema describes the spatial data that is transformed from PostGIS into tiles. Schemas consist of three parts:
Each layer represents one SQL query, containing returned geometry. Selected geometries for x/y/z tile requests are merged and served as a zipped tile.
A schema is stored in a .yml file and is treated like any other supported tiles format (MBTiles, GeoPackage).
On the Tiles page, click on the New Tiles button.
Next, click on the Create schema button.
Then fill in the individual connection properties or at least one connection string, and then click Connect.
Select the geometry column(s) you want to serve as tile layer(s) and press Continue.
Now, you should see a preview of the created layer(s). Here you can edit the tile’s properties, including zoom levels defining where the layer should be visible. Now press Save.
A dialog with a metadata form should open, where you should fill in the name of the created tiles and press Save again to create the schema.
The new vector tiles schema will be displayed as a .yml file within the working directory, and tiles will be served from it. Open these tiles by clicking on the Detail button.
You can edit a selected schema with a click on the Edit schema button, or you can directly use it in your map by clicking on the Add to Map button.
Select one of your existing map styles to use as a base map behind the new tiles. As a result, a new map style will be created (the base map style will stay untouched). Fill in the new map’s name and press the Save button.
Your new map using tiles from your PostGIS source should appear in the Maps section.
A style for the added PostGIS layers is generated, which you may want to edit. MapTiler Server does not yet include a GUI interface for style editing/customization, so you will have to edit the style.json manually to make changes.
That’s it! Now you know how to connect MapTiler Server to a PostgreSQL database with PostGIS and serve the data within as vector tiles. Get started now to serve real-time spatial data from PostgreSQL with MapTiler Server, fully integrated with your custom MapTiler basemaps.
Download MapTiler Server
Add data to MapTiler Server
Please sign in to leave a comment.