Compute an isochrone with Thinwrap (Elixir)

Compute a travel-time or travel-distance polygon via :thinwrap_location.isochrone/2 in Elixir — one call shape for Mapbox, HERE, ESRI and TomTom.

1. Install

{:thinwrap_location, "~> 1.3"}

2. Send the call

config = %{provider: :mapbox, access_token: System.fetch_env!("MAPBOX_ACCESS_TOKEN")}

case :thinwrap_location.isochrone(config, %{
       center: %{lat: 52.5200, lng: 13.4050},
       type: :time,
       # seconds
       values: [300, 600],
       travel_mode: :driving
     }) do
  # Each contour carries a GeoJSON Polygon (or MultiPolygon) of [lng, lat] rings.
  {:ok, %{contours: contours}} ->
    for %{value: value, geometry: geometry} <- contours do
      IO.puts("#{value} #{geometry.type} #{length(geometry.coordinates)}")
    end

  {:error, %{code: code, message: message}} ->
    IO.puts("#{code}: #{message}")
end

Same code works for all supported providers — just change the provider ID.