Snap a coordinate to the nearest road
client.routing.nearestPost(RoutingNearestPostParams { lat, lng, outputFields, 3 more } params, RequestOptionsoptions?): NearestResult { geometry, properties, type }
POST/api/v1/nearest
Snap a coordinate to the nearest road
import Plaza from '@plazafyi/sdk';
const client = new Plaza({
apiKey: process.env['PLAZA_API_KEY'], // This is the default and can be omitted
});
const nearestResult = await client.routing.nearestPost({ lat: 0, lng: 0 });
console.log(nearestResult.geometry);{
"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"
}