Skip to content
GuidesPlaygroundDashboard

Snap a coordinate to the nearest road

$client->routing->nearest(float lat, float lng, ?int radius): NearestResult
GET/api/v1/nearest

Snap a coordinate to the nearest road

ParametersExpand Collapse
lat: float

Latitude

lng: float

Longitude

radius?:optional int

Search radius in meters (default 500, max 5000)

ReturnsExpand Collapse
Properties properties
Type type

Snap a coordinate to the nearest road

<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$client = new Client(apiKey: 'My API Key', environment: 'local');

$nearestResult = $client->routing->nearest(lat: 0, lng: 0, radius: 0);

var_dump($nearestResult);
{
  "geometry": {
    "coordinates": [
      0
    ],
    "type": "Point"
  },
  "properties": {
    "distance_m": 0,
    "edge_id": 0
  },
  "type": "Feature"
}
Returns Examples
{
  "geometry": {
    "coordinates": [
      0
    ],
    "type": "Point"
  },
  "properties": {
    "distance_m": 0,
    "edge_id": 0
  },
  "type": "Feature"
}