Use case
Commute-time maps
A commute-time map shows how far someone can travel from a workplace in ten, twenty or thirty minutes, as nested shapes on a map. With oslew you geocode the workplace, request one isochrone per band, convert each to GeoJSON on your server and draw them over the vector basemap with MapLibre GL JS. The bands are computed at free-flow speeds, so present them as off-peak reach rather than as the rush-hour commute.
Last reviewed
A flat listing, an office move or a clinic’s catchment all raise the same question — how far do you get in ten, twenty or thirty minutes — and the answer people understand is a shape on a map. Building that shape into a page takes four small pieces of work: placing the workplace, fetching the bands, turning them into GeoJSON, and serving a basemap through your own server so the key never reaches the browser.
What the page is built from
- The geocoding API turns the workplace’s address into a point. It uses the address rate.
- The isochrone API returns everywhere reachable from that point within each band’s budget. It uses the routing rate.
- The maps API serves the vector tiles, TileJSON and MapLibre style for the basemap. It uses the platform rate.
The Platform plan, at $699 a month, carries all three products, with 20 requests a second sustained, burst 100 for routing. The commute map example is the complete server and page, in Python and TypeScript.
Placing the workplace
Geocode the address once, on the server, and keep the point. Check the answer before trusting it: a street-level precision or a tie at the top means the pin could be in the wrong place, and every band inherits that error. A map that lets the user drag the pin to the right building, and stores the corrected point, avoids arguing with the geocoder about an office entrance.
Fetching the bands
Ask for one isochrone per band — ten, twenty and thirty minutes are the usual set — with the travel mode as profile and a cell level to suit it. Coarser cells for longer reach keep the answer small and the outline smooth: level 13 for driving, level 14 for cycling and level 15 for walking work well. Each band is its own request, so three bands cost three requests on the routing rate. The answer changes only with a new data release, so cache it per point, mode and budget; a listings site with thousands of properties and a handful of workplaces pays for each workplace once.
Turning rings into GeoJSON
The isochrone’s polygon needs four things done before MapLibre will draw it as intended, and all of them belong in your server:
- Swap each pair. The service writes latitude first; GeoJSON wants longitude first.
- Close each ring by repeating its first corner at the end.
- Tell outlines from holes. Both arrive in one unlabelled list. Outlines all wind one way and holes the other, and the largest ring is always an outline, so the sign of each ring’s area sorts them.
- Give each hole to its outline, the one that contains the hole’s centre, because a GeoJSON polygon is an outline followed by its own holes.
Send the result as a FeatureCollection with the band’s minutes as a property. One quirk is worth knowing: where two reached cells touch only at a corner, the outline may pass through that corner or split there, and which one you get can vary between calls. The area covered is the same either way, so compare areas, not ring coordinates.
Serving the basemap from your own origin
Tile URLs carry no credential and the service sends no CORS headers, so the basemap is proxied too. Your server fetches the style and rewrites its source to point at your own TileJSON; fetches the TileJSON and rewrites its tile template to your own tile route; and passes tile requests through with the key attached. Tiles are stored gzipped: some HTTP clients hand them over still compressed and others unpack them, so check the first two bytes before deciding whether to send a gzip content-encoding header. A 204 means there is no tile there — open water, or deeper than the archive goes — and MapLibre overzooms the deepest tile itself. Every tile is a request on the platform rate, and a user panning a map asks for dozens, so cache tiles in memory and send a Cache-Control header so the browser keeps them as well.
The style points MapLibre at a public demo font server for labels, so every visitor’s browser fetches fonts from a third party. For production, host the glyphs yourself and rewrite that URL in the style your server hands out.
Drawing the bands
Add the FeatureCollection as a GeoJSON source and draw the bands largest first at low opacity, so the centre — reached within every budget — comes out darkest. Colour them by the minutes property, and insert both the fill and the outline layer beneath the first symbol layer of the style, so street names stay readable over the shapes. Keep MapLibre’s attribution control: the basemap and the roads behind the bands are ODbL data, and the licensing page covers what storing or republishing the shapes involves.
What to tell the people looking at it
The map is only as honest as its caption. Travel times behind the bands are free-flow — each road at its posted limit or its class’s speed, nothing for signals or queues — so a thirty-minute driving band at eight in the morning is larger than the area anyone actually reaches by then. Free-flow versus traffic-aware routing explains why, and the choice is between three honest presentations:
- Caption driving bands as off-peak: “reachable in light traffic”.
- Shrink the budgets for a peak-hour view, calibrated against a few commutes you know.
- Lead with walking and cycling, which congestion affects far less.
Two more things belong in the small print. The edge of a band is accurate to a cell, not to a street, so a house just inside the line may be just outside in reality. And the bands measure outward from the workplace; on a one-way network the morning drive in can differ from the evening drive out. When a user picks a specific home, route from it to the workplace and show that time — it answers for the address and in the right direction. Traffic-aware bands are possible only where an Enterprise operator has applied a traffic feed; the answer’s engine field says whether one was used.
Bottom line
Geocode the workplace once, fetch one band per budget at a level suited to the mode, convert the rings on your server, proxy the basemap, and draw the bands under the labels. Caption driving bands as off-peak, and switch to a route when the question becomes one home’s commute.
Where this workflow falls short
- Bands are computed at free-flow speeds, so at peak hours a driving band covers more ground than commuters actually reach; caption it as off-peak unless an Enterprise operator traffic feed is in force.
- A cell counts as reached if any road junction inside it was, so each band’s edge can overstate reach by up to one cell, and there are holes where there are no roads.
- Bands are measured outward from the workplace; on one-way networks the drive in from a home can take a different time from the drive out to it.
- The basemap and the isochrones both derive from ODbL data; keep the map’s attribution visible and read the licensing terms before storing or republishing the shapes.
Questions
Can the browser call the isochrone API directly?
No. The service sends no CORS headers and a key belongs only in a server’s Authorization header, so the browser talks to your server and your server talks to oslew. The same applies to the basemap: serve the style, the TileJSON and the tiles through your own origin.
Which cell level suits a commute map?
The coarsest level that still looks right at the zoom you draw. Driving bands that cross a city read well at level 13, cycling bands at level 14 and walking bands at level 15. Each step finer means about four times as many cells for the same area, so the answer and the drawing both grow quickly.
How many requests does a three-band map take?
Three isochrone requests, one per band, each counted once against the routing rate, plus one geocode for the workplace on the address rate. Cache the bands per workplace and travel mode: they change only with a new data release, unless an operator’s traffic feed is in use.
How should the map describe a rush-hour commute?
As an estimate for clear roads. The bands use free-flow speeds, so for a peak-hour drive either caption them as off-peak reach or ask for smaller budgets. Walking and cycling bands are affected far less by congestion, and give a fairer picture of a daily commute on foot or by bicycle.
Can the map show the commute from one particular home?
Not from the bands, which answer for cells rather than addresses. When a user picks a home, geocode it and route from the home to the workplace, or use a matrix row when ranking many homes, and show that time beside the shapes. It also answers in the direction the commute is actually made.