Roads API는 최대 100개의 독립된 좌표를 취하고 각 지점에 대한 가장 가까운 도로 구간을 반환합니다. 전달된 지점은 연속 경로의 일부일 필요가 없습니다.
순차적 GPS 지점을 사용하여 작업하는 경우 도로에 스냅하기를 사용합니다.
요청
가장 가까운 도로에 대한 요청은 HTTPS를 통해 전송해야 하며 양식:
https://roads.googleapis.com/v1/nearestRoads?parameters&key=YOUR_API_KEY
Required parameters
points
The points to be snapped. The points parameter accepts a list of latitude/longitude pairs. Separate latitude and longitude values with commas. Separate coordinates with the pipe character: "|". For example:
points=60.170880,24.942795|60.170879,24.942796|60.170877,24.942796
.
예
다음 요청은 지정된 좌표 목록에 기반한 도로 구간 집합을 반환합니다.
URL
https://roads.googleapis.com/v1/nearestRoads ?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796 &key=YOUR_API_KEY
cURL
curl -L -X GET 'https://roads.googleapis.com/v1/nearestRoads?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796&key=YOUR_API_KEY'
대답
올바른 각 요청에 대해, Roads API는 요청 URL에 내에 나타난 형식으로 응답을 반환합니다.
{ "snappedPoints": [ { "location": { "latitude": 60.170878428876755, "longitude": 24.94269540970182 }, "originalIndex": 0, "placeId": "ChIJfVFHrM0LkkYRBzUQos_jR5w", }, { "location": { "latitude": 60.17087741412199, "longitude": 24.942695474405202 }, "originalIndex": 1, "placeId": "ChIJfVFHrM0LkkYRBzUQos_jR5w", }, { "location": { "latitude": 60.170875416131736, "longitude": 24.942695601802203 }, "originalIndex": 2, "placeId": "ChIJfVFHrM0LkkYRBzUQos_jR5w", }, ], }
응답은 다음 스키마를 사용합니다.
NearestRoadsResponse
Field | Required | Type | Description |
---|---|---|---|
| optional | Array<SnappedPoint> | An array of snapped points. Sometimes containing several snapped points for the same point with differing placeId or location. See SnappedPoint for more information. |
SnappedPoint
Field | Required | Type | Description |
---|---|---|---|
| required | LatitudeLongitudeLiteral | See LatitudeLongitudeLiteral for more information. |
| required | string | A unique identifier for a place. All place IDs returned by the Roads API correspond to road segments. |
| optional | number |
An integer that indicates the corresponding value in the original
request. Each value in the request should map to a snapped value in
the response. However, if you've set interpolate=true or if you're
using nearest roads, then it's possible that the response will
contain more coordinates than the request. Interpolated values will
not have an |
LatitudeLongitudeLiteral
An object describing a specific location with Latitude and Longitude in decimal degrees.
Field | Required | Type | Description |
---|---|---|---|
| required | number | Latitude in decimal degrees |
| required | number | Longitude in decimal degrees |