API Distance Matrix
Introduce
The Distance Matrix is an API used to calculate distances and travel times between multiple points on the map
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 obtained from TOPTOP Maps |
origin | string | Required. Starting coordinates, for example: 20.981971,105.864323 |
destination | string | Required. Ending coordinates, for example: 21.03876,105.79810 |
mode | string | Required. Vehicle type, for example: car or bike |
weighting | string | Required. Sort results by: 0 for shortest; 1 for fastest, for example: 1 |
Sample request
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 |