Routing
← Back to the table of contents
Response Structure¶
JS response (JSON)
• JSON Parameters
• JSON Sample responses
GPX response
JS response (JSON)¶
{
version:0.3,
status: 0 - OK, 1 - Error,
status_message: Error message string,
route_summary: {
total_distance: Distance in meters,
total_time: Estimated time in seconds,
start_point: Name of the start point of the route,
end_point: Name of the end point of the route,
transit_points: [[point_name,lat,lon],...,[point_nameN,latN,lonN]] - Transit points if they are present in request.
},
route_geometry: [Array of nodes from start to end in 4326 projection ([lat1,lon1],...,[latM,lonM])]
route_instructions: [[instruction, length, position, time, length_caption, earth_direction, azimuth, turn_type, turn_angle ],...,[instructionN, lengthN, ...]]
}
JSON Parameters¶
| Name | Type | Explanation |
|---|---|---|
| instruction | String | text instruction, e.g. Turn left at Oxford Street |
| length | double | length of the segment in meters |
| position | int | index of the first point of the segment in route_geometry |
| time | int | estimated time required to travel the segment in seconds |
| length_caption | String | length of the segments in specified units e.g. 22m, 23.4 km, 14.4 miles |
| earth_direction | String | earth direction code of the start of the segment (now only 8 directions are supported, N, NE, E, SE, S, SW, W, NW) |
| azimuth | double | north-based azimuth |
| turn_type | String | code of the turn type, optional, absent for the first segment |
| turn_angle | degree | angle in degress of the turn between two segments, 0 for go straight, 90 for turn right, 270 for turn left, 180 for U-turn |
| turn_type parameter can be: | |
|---|---|
| C | continue (go straight) |
| TL | turn left |
| TSLL | turn slight left |
| TSHL | turn sharp left |
| TR | turn right |
| TSLR | turn slight right |
| TSHR | turn sharp right |
| TU | U-turn |
JSON Sample responses¶
{"status":0,"route_instructions":[
["Head south on Perckhoevelaan",111,0,13,"0.1 km","S",160.6],
["Turn left at Laarstraat",112,3,13,"0.1 km","NE",58.1,"TL",269.0],
["Turn right at Goudenregenlaan",70,5,8,"70 m","SE",143.4,"TR",89.8]],
"route_summary":{"total_time":34,"total_distance":293,"end_point":"Goudenregenlaan","start_point":"Perckhoevelaan"},
"route_geometry":[[51.17702,4.3963],[51.17656,4.39655],[51.17639,4.3967],[51.17612,4.39696],[51.1764,4.39767],[51.17668,4.39828],[51.17628,4.39874],[51.17618,4.39888]],
"version":"0.3"}routingLoaded(RESPONSE_FROM_PREVIOUS_SAMPLE);
{
version:0.3,
status: 1,
status_message: "Unable to find a road within 10 km of the start point, try another one"
}
GPX response¶
Sample response formatted for better reading¶
<?xml version="1.0" encoding="UTF-8"?>
<gpx creator="" version="1.1" xmlns="http://www.topografix.com/GPX/1/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 gpx.xsd ">
<extensions>
<distance>293</distance>
<time>34</time>
<start>Perckhoevelaan</start>
<end>Goudenregenlaan</end>
</extensions>
<wpt lat="51.17702" lon="4.39630" />
<wpt lat="51.17656" lon="4.39655" />
<wpt lat="51.17639" lon="4.39670" />
<wpt lat="51.17612" lon="4.39696" />
<wpt lat="51.17640" lon="4.39767" />
<wpt lat="51.17668" lon="4.39828" />
<wpt lat="51.17628" lon="4.39874" />
<wpt lat="51.17618" lon="4.39888" />
<rte>
<rtept lat="51.17702" lon="4.39630">
<desc>Head south on Perckhoevelaan, 0.1 km</desc>
<extensions>
<distance>111</distance>
<time>13</time>
<offset>0</offset>
<distance-text>0.1 km</distance-text>
<direction>S</direction>
<azimuth>160.6</azimuth>
</extensions>
</rtept>
<rtept lat="51.17612" lon="4.39696">
<desc>Turn left at Laarstraat, 0.1 km</desc>
<extensions>
<distance>112</distance>
<time>13</time>
<offset>3</offset>
<distance-text>0.1 km</distance-text>
<direction>NE</direction>
<azimuth>58.1</azimuth>
<turn>TL</turn>
<turn-angle>269.0</turn-angle>
</extensions>
</rtept>
<rtept lat="51.17668" lon="4.39828">
<desc>Turn right at Goudenregenlaan, 70 m</desc>
<extensions>
<distance>70</distance>
<time>8</time>
<offset>5</offset>
<distance-text>70 m</distance-text>
<direction>SE</direction>
<azimuth>143.4</azimuth>
<turn>TR</turn>
<turn-angle>89.8</turn-angle>
</extensions>
</rtept>
</rte>
</gpx>
Extensions tags used to pass more information about the route have intuitive names and are similar to the JSON analogs described in the previous section.
Start Developing
Use our location services for:
- games
- apps with maps
- social apps
- travel
- and other types of apps ...
