Compute an isochrone with Thinwrap (PHP)

Compute a travel-time / travel-distance polygon (isochrone) via the Thinwrap unified Isochrone facade in PHP — same call shape for Mapbox, HERE, ESRI, and TomTom.

1. Install

composer require thinwrap/location

2. Send the call

use Thinwrap\Location\Isochrone;
use Thinwrap\Location\Config\MapboxConfig;
use Thinwrap\Location\DTO\Isochrone\IsochroneOptions;
use Thinwrap\Location\DTO\LatLng;
use Thinwrap\Location\Enum\IsochroneType;
use Thinwrap\Location\Enum\LocationProviderId;
use Thinwrap\Location\Enum\TravelMode;

$isochrone = new Isochrone(
    LocationProviderId::Mapbox,
    new MapboxConfig(accessToken: getenv('MAPBOX_TOKEN')),
);

$result = $isochrone->isochrone(new IsochroneOptions(
    center: new LatLng(37.7749, -122.4194),
    type: IsochroneType::Time,        // ::Time (seconds) or ::Distance (meters)
    values: [300, 600, 900],          // 5, 10, 15 min; capped at 4 per request
    travelMode: TravelMode::Driving,  // base shape: Driving | Walking
));

// ->isochrones[] — one polygon per requested value, sorted ascending.
foreach ($result->isochrones as $iso) {
    echo $iso->value, ' second band, polygon vertices: ',
         count($iso->polygon), PHP_EOL;
}

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