Nhảy tới nội dung

Routing APIs (bike, walking, car)

API Directions hay còn được biết đến là API chỉ đường, cho phép bạn tích hợp khả năng định vị, định tuyến cho các ứng dụng web hoặc ứng dụng điện thoại.

mẹo

Hãy sử dụng Enterprise Dashboard hoặc hướng dẫn API Key để tạo API Key và trải nghiệm miễn phí!

Click để hiểu tính năng này rõ hơn

Base URL

Mã URL chung cho tất các yêu cầu API: https://mapapis.openmap.vn/v1

Endpoint

GET /direction

Ví dụ

Yêu cầu:

/direction?origin=10.78746,106.69855&destination=10.79135,106.70238&vehicle=car&apikey=YOUR_API_KEY

Tham số để yêu cầu

Tham sốKiểu dữ liệuBắt buộcMặc địnhMổ tảVí dụ
originstringKhông cóTọa độ điểm bắt đầu21.0267400,105.7740100
destinationstringKhông cóTọa độ điểm kết thúc, nếu có nhiều hơn 2 điểm kết thúc, hãy tách các tọa độ bằng dấu ;21.0196200,105.8576430
alternativesBooleanKhôngtrueNếu đặt giá trị là true hệ thống có thể sẽ trả về nhiều hơn 1 tuyến đườngtrue
vehiclestringKhôngcarCác lựa chọn về phương tiện, có các lựa chọn như car,bike,motor,taxi,truck,walkingcar

Trả về:

{
"geocoded_waypoints": [
{
"geocoder_status": "OK",
"place_id": "aDpeRUVL2x1AdDRBA7hDHZIKgn98vRK8RgkI4XSm-2rhyHnRCK5GxdCtWThA"
},
{
"geocoder_status": "OK",
"place_id": "PlopbmUIDBBLUVJUyq6O8Ek5XJQE5gr5SqVosbjiqvRJbUINeN1S9U1JHgRg"
}
],
"routes": [
{
"bounds": {},
"legs": [
{
"distance": {
"text": "1.76 km",
"value": 1762
},
"duration": {
"text": "2 minutes",
"value": 143
},
"end_address": "谭木匠, ",
"end_location": {
"lat": 107.91379,
"lng": 1067.02345
},
"start_address": "谭木匠, ",
"start_location": {
"lat": 107.87421,
"lng": 1066.98593
},
"steps": [
{
"distance": {
"text": "280 m",
"value": 280
},
"duration": {
"text": "20 seconds",
"value": 20
},
"end_location": {
"lat": 107.85587,
"lng": 1066.9685
},
"html_instructions": "Start at Nguyễn Đình Chiểu",
"maneuver": "",
"polyline": {
"points": "ydlqSaujojEvN|MpEjEnEdEbG`GtV~T~t@jr@"
},
"start_location": {
"lat": 107.87421,
"lng": 1066.98593
},
"travel_mode": "DRIVING"
},
{
"distance": {
"text": "316 m",
"value": 316
},
"duration": {
"text": "33 seconds",
"value": 33
},
"end_location": {
"lat": 107.87535,
"lng": 1066.94743
},
"html_instructions": "Turn right onto Phùng Khắc Khoan",
"maneuver": "right",
"polyline": {
"points": "erhqSchgojEc|@baAs{@p`A"
},
"start_location": {
"lat": 107.85587,
"lng": 1066.9685
},
"travel_mode": "DRIVING"
},
{
"distance": {
"text": "718 m",
"value": 718
},
"duration": {
"text": "53 seconds",
"value": 53
},
"end_location": {
"lat": 107.92129,
"lng": 1066.99339
},
"html_instructions": "Turn right onto Đường Ðiện Biên Phủ",
"maneuver": "right",
"polyline": {
"points": "}klqSmdcojEyY}XmXiX}WaXsBqBeH}Gi^{\\cDcDoKmKgFeFg[wVsCcCyCmE{BaCk]o[qKaK{UcUgP{QiO{V"
},
"start_location": {
"lat": 107.87535,
"lng": 1066.94743
},
"travel_mode": "DRIVING"
},
{
"distance": {
"text": "36 m",
"value": 36
},
"duration": {
"text": "4 seconds",
"value": 4
},
"end_location": {
"lat": 107.92218,
"lng": 1066.99654
},
"html_instructions": "Turn Nguyễn Bỉnh Khiêm",
"maneuver": "slight right",
"polyline": {
"points": "akuqSuclojE@cAAy@IoAMcAYuASy@YeAYs@]u@Yc@"
},
"start_location": {
"lat": 107.92129,
"lng": 1066.99339
},
"travel_mode": "DRIVING"
},
{
"distance": {
"text": "279 m",
"value": 279
},
"duration": {
"text": "19 seconds",
"value": 19
},
"end_location": {
"lat": 107.90494,
"lng": 1067.01513
},
"html_instructions": "Turn right onto Nguyễn Bỉnh Khiêm",
"maneuver": "right",
"polyline": {
"points": "spuqSkwlojEbOoPzDmEzG}FbOwPpGiHdQqRxCmDtMkOnM{N"
},
"start_location": {
"lat": 107.92218,
"lng": 1066.99654
},
"travel_mode": "DRIVING"
},
{
"distance": {
"text": "134 m",
"value": 134
},
"duration": {
"text": "11 seconds",
"value": 11
},
"end_location": {
"lat": 107.91379,
"lng": 1067.02345
},
"html_instructions": "Turn left onto Nguyễn Đình Chiểu",
"maneuver": "left",
"polyline": {
"points": "{drqSqkpojEmm@mk@{GqF"
},
"start_location": {
"lat": 107.90494,
"lng": 1067.01513
},
"travel_mode": "DRIVING"
},
{
"distance": {
"text": "0 m",
"value": 0
},
"duration": {
"text": "0 seconds",
"value": 0
},
"end_location": {
"lat": 107.91379,
"lng": 1067.02345
},
"html_instructions": "You have arrived at your destination",
"maneuver": "right",
"polyline": {
"points": "e|sqSq_rojE??"
},
"start_location": {
"lat": 107.91379,
"lng": 1067.02345
},
"travel_mode": "DRIVING"
}
]
}
],
"overview_polyline": {
"points": "ydlqSaujojEvN|MpEjEnEdEbG`GtV~T~t@jr@c|@baAs{@p`AyY}XmXiX}WaXsBqBeH}Gi^{\\cDcDoKmKgFeFg[wVsCcCyCmE{BaCk]o[qKaK{UcUgP{QiO{V@cAAy@IoAMcAYuASy@YeAYs@]u@Yc@bOoPzDmEzG}FbOwPpGiHdQqRxCmDtMkOnM{Nmm@mk@{GqF"
},
"summary": "",
"warnings": [],
"waypoint_order": []
}
]
}