Skip to content

Route

Route


A Route Maps API is a feature provided by VIETMAP that allows developers to calculate and display the optimal route between two or more locations on a map. With a Route Maps API, developers can specify the start and end points of a journey, along with any additional constraints such as preferred mode of transportation, and retrieve a detailed route that can be displayed on a map. The API may also provide information such as the total distance, estimated travel time, and turn-by-turn directions. Developers can use Route Maps APIs to create applications that help with navigation, transportation planning, and logistics management.

URL

https://maps.vietmap.vn/api/route?api-version=1.1&apikey={your-apikey}&point={point}&point={point}&points_encoded={points_encoded}&vehicle={vehicle}&optimize={optimize}

Method

GET

Parameters

Parameter Type Required Default Description
point array string yes none The points for which the route should be calculated. Format: [latitude,longitude]. Specify at least an origin and a destination. Via points are possible. The maximum number depends on your plan.
Example query: &point=lat,lng
points_encoded boolean no true Allows changing the encoding of location data in the response. The default is polyline encoding, which is compact but requires special client code to unpack. Set this parameter to false to switch the encoding to simple coordinate pairs like [lon,lat]. See the description of the response format for more information.
We suggest this query should receive true value to decrease the size of the response JSON.
vehicle string no car Enum: car, bike, foot, motorcycle. Config the vehicle profiles for which the route should be calculated.
optimize string no false Execute TSP if the value = true

Example

Input

https://maps.vietmap.vn/api/route?api-version=1.1&apikey={your-apikey}&point=10.79628438955497,106.70592293472612&point=10.801891047584164,106.70660958023404&vehicle=motorcycle
Response

{
    "license": "vietmap",
    "code": "OK",
    "messages": null,
    "paths": [
        {
            "distance": 2194.4,
            "weight": 351.4,
            "time": 351400,
            "transfers": 0,
            "points_encoded": true,
            "bbox": [
                106.70594,
                10.79479,
                106.71154,
                10.80325
            ],
            "points": "}s{`Ac_hjSjAkCFQRu@Lu@F_@D]Ng@ZaALa@JY~AoDDEmBiBe@[WMg@M_@KmA]uA_@a@KkA]qA[[Gs@MUE_AKu@Co@Ew@CYAmAGeBKaAEsAKCQMQUGM?KBIFGHCJoBO{@Ck@AQ@MZAJAjAG|ACz@MnCEnAGlBCx@EjA?\\EvAEjBE~@Cr@F?HqBv@DBSDIBAl@HFADAVSD@JLB@h@BDADEDAJ@",
            "instructions": [
                {
                    "distance": 403.4,
                    "heading": 0,
                    "sign": 0,
                    "interval": [
                        0,
                        11
                    ],
                    "text": "Tiếp tục theo Nguyễn Cửu Vân",
                    "time": 54800,
                    "street_name": "Nguyễn Cửu Vân",
                    "last_heading": null
                },
                /// More guide direction here
                {
                    "distance": 58.7,
                    "heading": 0,
                    "sign": 0,
                    "interval": [
                        71,
                        79
                    ],
                    "text": "Tiếp tục theo Đường Không Tên",
                    "time": 26300,
                    "street_name": "Đường Không Tên",
                    "last_heading": null
                },
                {
                    "distance": 0,
                    "heading": 0,
                    "sign": 4,
                    "interval": [
                        79,
                        79
                    ],
                    "text": "Đích đến",
                    "time": 0,
                    "street_name": "Đường Không Tên",
                    "last_heading": null
                }
            ],
            "snapped_waypoints": "c_hjS}s{`AeDab@"
        }
    ]
}

Response description

Parameter Type Description
license string License type associated with the routing data
code string Status code indicating the success or failure of the request
messages string Additional messages related to the request (if any)
paths array Array containing route information including distance, time, etc.

For each route in the paths array:

Sub-Parameter Type Description
distance number Total distance of the route (in meters)
weight number Weight assigned to the route
time int Total time required for the route (in milliseconds)
transfers int Number of transfers required for the route
points_encoded boolean Indicates if the points are encoded
bbox array Bounding box coordinates of the route
points string Encoded points representing the route using google polyline 5 format. If the points_encoded is false, points will response a list of [lat,lng] format.
instructions array Array containing turn-by-turn navigation instructions
snapped_waypoints string Snapped waypoints representing the route (if available)

For each navigation instruction in the instructions array:

Sub-Parameter Type Description
distance double Distance until the next instruction (in meters)
heading int Heading direction of the instruction (if available)
sign int Direction sign of the instruction (0 for straight, -2 for left, 2 for right, etc.)
interval array Interval indices indicating the start and end of the instruction
text string Textual description of the instruction
time int Time required for the instruction (in milliseconds)
street_name string Name of the street for the instruction
last_heading null Last heading direction of the instruction (if available)