## Snap a coordinate to the nearest road `client.routing.nearest(RoutingNearestParamsquery, RequestOptionsoptions?): NearestResult` **get** `/api/v1/nearest` Snap a coordinate to the nearest road ### Parameters - `query: RoutingNearestParams` - `lat: number` Latitude - `lng: number` Longitude - `radius?: number` Search radius in meters (default 500, max 5000) ### Returns - `NearestResult` GeoJSON Point Feature snapped to the nearest road segment - `geometry: GeoJsonGeometry` - `coordinates: Array | Array> | Array>> | Array>>>` GeoJSON coordinates array (nesting depth varies by geometry type) - `Array` - `Array>` - `Array>>` - `Array>>>` - `type: "Point" | "LineString" | "Polygon" | 3 more` - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `properties: Properties` - `distance_m?: number` Distance to nearest road in meters - `edge_id?: number | null` Road edge ID - `type: "Feature"` - `"Feature"` ### Example ```typescript 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.nearest({ lat: 0, lng: 0 }); console.log(nearestResult.geometry); ``` #### Response ```json { "geometry": { "coordinates": [ 0 ], "type": "Point" }, "properties": { "distance_m": 0, "edge_id": 0 }, "type": "Feature" } ```