Skip to content
Last updated

You can get a distance matrix by sending an HTTP GET request

The following example shows the URL of a REST request to the distance matrix:

https://dplace-api.themap.world/maps/api/distancematrix/json?origins=[{coordinate}|...]&destinations=[{coordinate}|...]&option=value&key=YOUR_API_KEY

Include your request options in the query parameters.

Example: HTTP distance matrix request

curl -X GET \
--header 'Content-Type: application/json' \
'https://dplace-api.themap.world/maps/api/distancematrix/json?origins=10.82587263527185%2C106.72299739871045%7C10.830553365061235%2C106.72882248366415&destinations=10.838966767933428%2C106.7453836166307%7C10.841693331125839%2C106.76390321646471&key=YOUR_API_KEY'

Example: HTTP distance matrix response body

{
    "status": "OK",
    "rows": [
        {
            "elements": [
                {
                    "duration_in_traffic": {
                        "value": 0,
                        "text": ""
                    },
                    "status": "OK",
                    "duration": {
                        "value": 278,
                        "text": "4 mins 38 seconds"
                    },
                    "distance": {
                        "value": 3516,
                        "text": "4 km"
                    }
                },
                {
                    "duration_in_traffic": {
                        "value": 0,
                        "text": ""
                    },
                    "status": "OK",
                    "duration": {
                        "value": 520,
                        "text": "8 mins 39 seconds"
                    },
                    "distance": {
                        "value": 6431,
                        "text": "6 km"
                    }
                }
            ]
        },
        {
            "elements": [
                {
                    "duration_in_traffic": {
                        "value": 0,
                        "text": ""
                    },
                    "status": "OK",
                    "duration": {
                        "value": 266,
                        "text": "4 mins 26 seconds"
                    },
                    "distance": {
                        "value": 2835,
                        "text": "3 km"
                    }
                },
                {
                    "duration_in_traffic": {
                        "value": 0,
                        "text": ""
                    },
                    "status": "OK",
                    "duration": {
                        "value": 508,
                        "text": "8 mins 28 seconds"
                    },
                    "distance": {
                        "value": 5751,
                        "text": "6 km"
                    }
                }
            ]
        }
    ],
    "destination_addresses": [
        "Đường số 36",
        "Đặng Văn Bi"
    ],
    "origin_addresses": [
        "Đường số 20",
        "Đường Số 3"
    ]
}