Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

tegola

> 编程语言
Open source

Tegola is a Mapbox Vector Tile server written in Go

1.5K stars0 likes1 views
WebsiteGitHub

About

Tegola is a Mapbox Vector Tile server written in Go

Tegola

Tegola is a vector tile server delivering Mapbox Vector Tiles with support for PostGIS, GeoPackage and SAP HANA Spatial data providers. User documentation can be found at tegola.io

Features

  • Native geometry processing (simplification, clipping, make valid, intersection, contains, scaling, translation)
  • Mapbox Vector Tile v2 specification compliant.
  • An embedded viewer with an automatically generated style for quick data visualization and inspection.
  • Support for PostGIS and GeoPackage data providers. Extensible design to support additional data providers.
  • Support for several cache backends: file, s3, redis, azure blob store.
  • Cache seeding and invalidation via individual tiles (ZXY), lat / lon bounds and ZXY tile list.
  • Parallelized tile serving and geometry processing.
  • Support for Web Mercator (3857) and WGS84 (4326) projections.
  • Support for AWS Lambda.
  • Support for serving HTTPS.
  • Support for PostGIS ST_AsMVT.
  • Support for Prometheus observability.

Usage

tegola is a vector tile server
Version: v0.21.0

Usage:
  tegola [command]

Available Commands:
  cache       Manipulate the tile cache
  help        Help about any command
  serve       Use tegola as a tile server
  version     Print the version number of tegola

Flags:
      --config string   path to config file (default "config.toml")
  -h, --help            help for tegola

Use "tegola [command] --help" for more information about a command.

Running tegola as a vector tile server

  1. Download the appropriate binary of tegola for your platform via the release page.
  2. Set up your config file and run. By default, Tegola looks for a config.toml in the same directory as the binary. You can set a different location for the config.toml using a command flag:
./tegola serve --config=/path/to/config.toml

Server Endpoints

/

The server root will display the built-in viewer with an automatically generated style. For example:

/maps/:map_name/:z/:x/:y

Return vector tiles for a map. The URI supports the following variables:

  • :map_name is the name of the map as defined in the config.toml file.
  • :z is the zoom level of the map.
  • :x is the row of the tile at the zoom level.
  • :y is the column of the tile at the zoom level.
/maps/:map_name/:layer_name/:z/:x/:y

Return vector tiles for a map layer. The URI supports the same variables as the map URI with the additional variable:

  • :layer_name is the name of the map layer as defined in the config.toml file.
/capabilities

Return a JSON encoded list of the server's configured maps and layers with various attributes.

/capabilities/:map_name

Return TileJSON details about the map.

/maps/:map_name/style.json

Return an auto generated Mapbox GL Style for the configured map.

Configuration

The tegola config file uses the TOML format. The following example shows how to configure a mvt_postgis data provider. The mvt_postgis provider will leverage PostGIS's ST_AsMVT() function for the encoding of the vector tile.

Under the maps section, map layers are associated with data provider layers and their min_zoom and max_zoom values are defined.

Example config using Postgres 12+ / PostGIS 3.0 ST_AsMVT():

…
  • More information on PostgreSQL SSL modes can be found here.
  • More information on the mvt_postgis provider can be found here

Environment Variables

Config TOML

Environment variables can be injected into the configuration file. One caveat is that the injection has to be within a string, though the value it represents does not have to be a string.

The above config example could be written as:

toml
# register data providers
[[providers]]
name = "test_postgis"
type = "mvt_postgis"
uri = "${POSTGIS_CONN_STR}"  # database connection string
srid = 3857
max_connections = "${POSTGIS_MAX_CONN}"

SQL Debugging

The following environment variables can be used for debugging:

TEGOLA_SQL_DEBUG specify the type of SQL debug information to output. Currently, supporting two values:

  • LAYER_SQL will print layer SQL as they are parsed from the config file.
  • EXECUTE_SQL will print SQL that is executed for each tile request, and the number of items it returns or an error.

Usage

bash
$ TEGOLA_SQL_DEBUG=LAYER_SQL tegola serve --config=/path/to/conf.toml

The following environment variables can be used to control various runtime options on dataproviders that are NOT mvt_postgis:

TEGOLA_OPTIONS specify a set of options comma or space delimited. Supports the following options

  • DontSimplifyGeo to turn off simplification for all layers.
  • SimplifyMaxZoom={{int}} to set the max zoom that simplification will apply to. (14 is default)

Client side debugging

When debugging client side, it's often helpful to see an outline of a tile along with it's Z/X/Y values. To encode a debug layer into every tile add the query string variable debug=true to the URL template being used to request tiles. For example:

http://localhost:8080/maps/mymap/{z}/{x}/{y}.vector.pbf?debug=true

The requested tile will be encoded with a layer that has the name value set to debug and includes the three following features.

  • debug_outline is a line feature that traces the border of the tile
  • debug_text is a point feature in the middle of the tile with the following tags:
  • zxy is a string with the Z, X and Y values formatted as: Z:0, X:0, Y:0

Building from source

Tegola is written in Go and requires Go 1.26.7 or higher to compile from the source. (We support the two newest versions of Go.) To build tegola from the source, make sure you have Go installed and have cloned the repository. Navigate to the repository then run the following command:

bash
go generate ... && cd cmd/tegola/ && go build -mod vendor

You will now have a binary named tegola in the current directory which is ready to run.

Build Flags The following build flags can be used to turn off certain features of tegola:

  • noAzblobCache - turn off the Azure Blob cache back end.
  • noS3Cache - turn off the AWS S3 cache back end.
  • noRedisCache - turn off the Redis cache back end.
  • noPostgisProvider - turn off the PostGIS data provider.
  • noGpkgProvider - turn off the GeoPackage data provider. Note, GeoPackage uses CGO and will be turned off if the environment variable CGO_ENABLED=0 is set prior to building.
  • noViewer - turn off the built-in viewer.
  • pprof - enable Go profiler. Start profile server by setting the environment TEGOLA_HTTP_PPROF_BIND environment (e.g. TEGOLA_HTTP_PPROF_BIND=localhost:6060).
  • noPrometheusObserver - turn off support for the Prometheus metric end point.

Example of using the build flags to turn of the Redis cache back end, the GeoPackage provider and the built-in viewer.

bash
go build -tags 'noRedisCache noGpkgProvider noViewer'

Setting Version Information The following flags can be used to set version information:

bash
# first set some env to make it easier to read:
BUILD_PKG=github.com/go-spatial/tegola/internal/build
VERSION=1.16.x
GIT_BRANCH=$(git branch --no-color --show-current)
GIT_REVISION=$(git log HEAD --oneline | head -n 1 | cut -d ' ' -f 1)

# build the go binary
go build -ldflags "-w -X ${BUILD_PKG}.Version=${VERSION} -X ${BUILD_PKG}.GitRevision=${GIT_REVISION} -X ${BUILD_PKG}.GitBranch=${GIT_BRANCH}"

License

See license file in the repo.

Looking for a vector tile style editor?

After Tegola is running you're likely going to want to work on your map's cartography. Give fresco a try!

Issues· 184 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gogisgolangmapbox-vector-tilemvt

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言