Skip to content

50,000 free calls a month, card-free. Get an API key →

Documentation menu
docs / examples / search-along-route
Example

Search along a route, with real detour costs

"Coffee, adds 4 min." Every candidate is costed leave-route, stop, rejoin against staying on the route, under your own costing, so a truck's detour is a truck's detour. Note the two surfaces search different data.

bash
export BASE=https://api.mapmap.ai
export API_KEY=snk_...

# POST /route/along searches YOUR OWN places dataset (the one you uploaded to
# PUT /places), not the world POI index. Truck parking within 5 km of a
# Dover to Birmingham truck route:
curl -fsS -X POST "$BASE/route/along" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "route": {
    "locations": [
      { "lat": 51.1279, "lon": 1.3134 },
      { "lat": 52.4862, "lon": -1.8904 }
    ],
    "costing": "truck",
    "costing_options": { "truck": { "height": 4.0, "weight": 40.0 } }
  },
  "category": "truck_parking",
  "corridor_m": 5000,
  "max_detours": 10
}'

# Hits are ranked by detour_seconds, cheapest stop first. along_fraction is
# how far along the route the stop sits, offset_m its straight-line distance
# from the line, and unreachable counts in-corridor candidates the engine
# could not connect. No dataset uploaded yet is an empty result, not an error.