Skip to content
Beyond Coordinates
Go back

Publishing Mapbox-Compatible Vector Tiles with GeoServer

Updated:

GeoServer is not the only way to publish vector tiles for Mapbox. Mapbox also provides its own tiling and hosting services. This article simply explains how to provide an equivalent vector tile service with GeoServer, which can be useful when avoiding hosted-data charges or deploying within a private network.

That said, Mapbox no longer appears to charge for data storage. And if an individual or company can deploy a map service on an internal network, generating vector tiles is probably not much of an obstacle either. So the exact use case for this approach may be narrower than it first appears.

Step 1: Install GeoServer

See the installation documentation.

Step 2: Enable Cross-Origin Access in GeoServer

See Enable CORS.

Step 3: Install the Vector Tiles Extension

Follow Installing the Vector Tiles Extension.

Step 4: Add MVT as an Output Format

Follow the Vector tiles tutorial.

Step 5: Load the Tiles in Mapbox

Example:

map.addSource("poi", {
  type: "vector",
  scheme: "tms",
  tiles: ["your server path"],
});
map.addLayer({
  id: "layer",
  type: "circle",
  source: "poi",
  "source-layer": "poi_source_layer",
  paint: {
    "circle-radius": 10,
    "circle-color": "Black",
  },
});

Notes on several parameters:

scheme: Select tms, the OSGeo tile addressing scheme. See vector-scheme.

Coordinate reference system: Use EPSG:900913 rather than EPSG:4326.

your server path:

http://127.0.0.1:8080/geoserver/gwc/service/tms/1.0.0/

china_city%3APoi@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf

— Example URL (no longer available)

This is admittedly a lightweight note. I originally investigated the GeoServer–Mapbox workflow because someone had posted an Upwork job specifically requesting it. I may add more substantial use cases if I encounter them later.


Share this post:

Previous Post
Running a Web Crawler on a Cloud Server
Next Post
The Lifecycle of a Mapbox Vector Tile