Reachable ranges
Important note Calculate Reachable Range is in Private Preview and unavailable on a Freemium or Pay As You Grow (PAYG) basis. Your API key needs access to it, and its API documentation requires a TomTom enterprise login. Click the Request Access button above to contact our Sales team.
calculateReachableRanges computes the area reachable from an origin within a budget — travel
time, distance, fuel or charge — and returns one GeoJSON polygon per budget. Several budgets from
one origin give concentric bands; calculateReachableRange computes a single one.
The demo below shows 10, 20 and 30 minutes of driving from two stations, drawn by the reachable ranges module in the map's own colours.
Budget types
Each range takes a budget of { type, value }:
timeMinutes– Travel time, in minutesdistanceKM– Distance, in kilometresremainingChargePCT– Battery left on arrival, as a percentagespentChargePCT– Battery spent, as a percentagespentFuelLiters– Fuel spent, in litres
budgetTypes lists them, as the BudgetType type does, and budgetUnits holds the unit each counts
in — all from @tomtom-org/maps-sdk/core, so a label of your own reads like the module's titles:
import { budgetUnits } from '@tomtom-org/maps-sdk/core';
const title = `${budget.value} ${budgetUnits[budget.type]}`; // '30 min', '20 % remaining'
Both charge budgets are a percentage of the battery, so they need a capacity to convert against, described under Vehicle configuration:
vehicle.engineType: 'electric'andvehicle.model.engine.charging.maxChargeKWH.- A predefined
model.variantIdkeeps its battery model on the service, so budget a variant by time or distance.
- A predefined
- For
remainingChargePCT, also the charge it sets off with:vehicle.state.currentChargePCTorcurrentChargeInkWh.
Example
import { ReachableRangesModule, TomTomMap } from '@tomtom-org/maps-sdk/map';
import { calculateReachableRanges } from '@tomtom-org/maps-sdk/services';
const origin: [number, number] = [4.9041, 52.3676];
const result = await calculateReachableRanges([
{ origin, budget: { type: 'timeMinutes', value: 10 } },
{ origin, budget: { type: 'timeMinutes', value: 20 } },
{ origin, budget: { type: 'timeMinutes', value: 30 } },
]);
const map = new TomTomMap({ mapLibre: { container: 'map', center: origin, zoom: 9 } });
const rangesModule = await ReachableRangesModule.create(map);
await rangesModule.show(result); // titled '30 min', '20 min', '10 min'
result.features– One polygon per range the service could calculate, in request order.result.bbox– The bounding box of them all.feature.properties– The request it was calculated with (origin,budget,vehicle, …), without the API key or any other common service parameter.- Ranges are calculated one after another rather than in parallel, to stay within the service's rate limit.
Range options
Beside vehicle, costModel and when, which work as on
calculateRoute within the limits below:
maxFerryLengthMeters– Ferries longer than this are left out, so a long crossing does not stretch the range.smoothing–'none','weak'or'strong'(default): how much the polygon's boundary is smoothed.
Display on the map
ReachableRangesModule draws the result unchanged — its guide
covers fill styles, band colours, titles, events and every setting:
const ranges = await ReachableRangesModule.create(map, { fillStyle: 'inverted' });
await ranges.show(result);
Ranges that can't be calculated
calculateReachableRanges skips a range the service answers with an error rather than rejecting
the batch. An origin the service can't match to a drivable road, such as a pedestrian square or a
point on water, answers NO_RANGE_FOUND:
result.featurescan be shorter than the request array, or empty. Match each feature to its request throughproperties.budgetandproperties.origin, and treat an empty result as "no range from this origin".calculateReachableRange, for a single range, rejects with that error instead.- A
401,403or429response, an aborted signal and an invalid request reject the batch.
Cancelling a batch
calculateReachableRanges takes one signal for the whole batch as its second argument; it cancels
the range in flight and skips the rest. When a new origin replaces the previous one, run the batch
through createLatestRequest,
as the reachable ranges example does on every map click:
import type { HasLngLat } from '@tomtom-org/maps-sdk/core';
import { calculateReachableRanges, createLatestRequest } from '@tomtom-org/maps-sdk/services';
const latestRanges = createLatestRequest();
const showRanges = async (origin: HasLngLat) => {
const ranges = await latestRanges.run((signal) =>
calculateReachableRanges(
[10, 20, 30].map((value) => ({ origin, budget: { type: 'timeMinutes', value } })),
{ signal },
),
);
if (!ranges.current) return; // a newer origin retired this batch
await rangesModule.show(ranges.value);
};
Unsupported options
The types leave these routing parameters out, and validation rejects them for untyped callers, rather than returning a range computed without them:
| Parameter | Use instead |
|---|---|
vehicle.state.heading |
Omit it, or use calculateRoute, which accepts it |
vehicle.preferences.chargingPreferences |
Omit them, or use calculateRoute, which plans charging stops |
costModel.avoid: 'alreadyUsedRoads' |
Drop that one entry — the other avoidables are accepted |
costModel.avoidAreas |
Omit it; this endpoint cannot avoid areas |
when.arriveBy |
Use when.departAt, or omit when entirely |
API reference
- calculateReachableRanges – A batch of ranges
- calculateReachableRange – A single range
- ReachableRangeParams – Request parameters
- ReachableRangeProperties – Properties of each result polygon
- Calculate Reachable Range API – API documentation (requires an enterprise login)
Related guides and examples
Related guides
- Reachable ranges module – Drawing the ranges: fill styles, colours, labels, events and every setting
- Vehicle configuration – The vehicle behind charge and fuel budgets
- Long distance EV routing – Routes with charging stops
- Geometries – Polygons of your own, styled per feature rather than as bands
Related examples
- Reachable ranges – Ranges around the clicked point, by time, distance, fuel or charge
- Reachable ranges playground – Every knob of the module, and bands following a map theme
- Routing composite – Ranges alongside a route and its places