maps for developers

The (former) official Mapbox blog. See mapbox.com/blog for current content.

Follow publication

Static API with overlays

By Bobby Sudekum

As of today, you can add custom overlays to your static maps when making requests to the Static Images API. This is useful in situations where JavaScript is not available or if you’re trying to keep your UI light. Take for example a ride-sharing app that sends a receipt to the user. In the receipt email they can show the route, pick up location, and dropoff location all with a single Static API request. Below is a ride-sharing receipt example with a sample request:

The Static Images API allows for 5 different types of overlays: GeoJSON styled with the simplestyle-spec, Maki marker, custom marker, an encoded polyline, or style parameters (a way to change the requested map style at render time). A single request can have a combination of overlay types and allows up to 100 features.

Since the Static Images API uses Mapbox GL, it’s possible to change where the overlay ends up in the style’s layer hierarchy. By specifying the query parameter before_layer, the overlays will be inserted before the specified layer in the style. This is great for putting data under labels.

Mapbox Static API with live traffic showing users morning commute
Show a user their morning commute with live traffic.

More examples

Highlighting parks in San Francisco, CA.

View the example request.

To get started with overlays on your static maps, check out the Static Images API documentation.

Written by Mapbox

mapping tools for developers + precise location data to change the way we explore the world

Responses (2)

Write a response