API Distance Matrix
Giới thiệu
Distance Matrix là API để tính toán khoảng cách và thời gian di chuyển giữa nhiều điểm trên bản đồ.
Params
GET https://dev.toptopmap.com/api/v1/maps/distance-matrix?key=APIKey&origins=21.1478048,105.4450751&destinations=21.0174578,105.7710966&mode=car
| Parameter | Type | Description |
|---|---|---|
key | string | Required. API Key lấy từ TOPTOP Maps |
origin | string | Required. Tọa độ bắt đầu, ví dụ: 20.981971,105.864323 |
destination | string | Required. Tọa độ kết thúc, ví dụ: 21.03876,105.79810 |
mode | string | Required.Loại phương tiện, ví dụ: car hoặc bike |
weighting | string | Required.Sắp xếp kết quả theo: 0 là ngắn nhất; 1 là nhanh nhất, ví dụ: 1 |
Request mẫu
curl --location 'https://dev.toptopmap.com/api/v1/distance-matrix?origins=10.74821917%2C106.661378311%7C10.7482432%2C106.6614453%7C10.7483532%2C106.6613751&destinations=21.03876%2C105.79810&mode=car&weighting=1'
Responses
{
"destination_addresses": [
"85 Ngõ 180 Đường Đình Thôn, Mỹ Đình, Nam Từ Liêm, Hà Nội, Việt Nam"
],
"origin_addresses": [
"thôn văn minh xã, 4CXW+632, Cam Thượng, Ba Vì, Hà Nội, Việt Nam"
],
"rows": [
{
"elements": [
{
"distance": {
"text": "55,4 km",
"value": 55432
},
"duration": {
"text": "1 giờ 10 phút",
"value": 4190
},
"status": "OK"
}
]
}
],
"status": "OK"
}
Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 400 | BAD REQUEST |
| 404 | NOT FOUND |
| 500 | INTERNAL SERVER ERROR |