Snap a coordinate to the nearest road
$client->routing->nearestPost(float lat, float lng, ?string outputFields, ?string outputInclude, ?int outputPrecision, ?int radius): NearestResult
POST/api/v1/nearest
Snap a coordinate to the nearest road
Parameters
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->nearestPost(
lat: 0,
lng: 0,
outputFields: 'output[fields]',
outputInclude: 'output[include]',
outputPrecision: 0,
radius: 0,
);
var_dump($nearestResult);{
"geometry": {
"coordinates": [
2.3522,
48.8566
],
"type": "Point"
},
"properties": {
"distance_m": 12.4,
"edge_id": 0,
"edge_length_m": 0,
"highway": "highway",
"osm_way_id": 0,
"surface": "surface"
},
"type": "Feature"
}Returns Examples
{
"geometry": {
"coordinates": [
2.3522,
48.8566
],
"type": "Point"
},
"properties": {
"distance_m": 12.4,
"edge_id": 0,
"edge_length_m": 0,
"highway": "highway",
"osm_way_id": 0,
"surface": "surface"
},
"type": "Feature"
}