Calculate Routes

Use the following URL template to get multiple routes by specifying a series of locations. A location is a specified geographical location defined by longitude and latitude that is used for navigational purposes. Every route includes information such as route instructions, travel duration, travel distance or transit information. You can also request a set of route points. Request type must be POST for both XML and JSON format.

http://trackservice.trackroad.com/rest/routeS/key

You must login to get a key.

For more details about request and response parameters see RoutesSpecification and RoutesResult.

ABSTRACT SAMPLE

XML

To receive response in XML format you must specify content type text/xml or application/xml. For example:

...
httpWReq.Method = "POST";
httpWReq.ContentType = "text/xml; charset=utf-8";
httpWReq.ContentLength = data.Length;
...

XML request

The following request uses two locations with Latitude/Longitude.

<RoutesSpecification>
  <Specifications>
    <RouteSpecification>
      <Locations>
        <Location>
          <Name>Loc_1</Name>
          <LatLong>
            <Latitude>38.951594</Latitude>
            <Longitude>-77.29602</Longitude>
          </LatLong>
        </Location>
        <Location>
          <Name>Loc_2</Name>
          <LatLong>
            <Latitude>38.908467</Latitude>
            <Longitude>-77.064874</Longitude>
          </LatLong>
        </Location>
      </Locations>
      <RouteOptions>
        <Culture>en-US</Culture>
        <DistanceUnit>Mile</DistanceUnit>
        <RouteOptimize>MinimizeTime</RouteOptimize>
      </RouteOptions>
    </RouteSpecification>
    <RouteSpecification>
      <Locations>
        <Location>
          <Name>Loc_1</Name>
          <LatLong>
            <Latitude>38.935594</Latitude>
            <Longitude>-77.28602</Longitude>
          </LatLong>
        </Location>
        <Location>
          <Name>Loc_2</Name>
          <LatLong>
            <Latitude>38.949467</Latitude>
            <Longitude>-77.136874</Longitude>
          </LatLong>
        </Location>
      </Locations>
      <RouteOptions>
        <Culture>en-US</Culture>
        <DistanceUnit>Mile</DistanceUnit>
        <RouteOptimize>MinimizeTime</RouteOptimize>
      </RouteOptions>
    </RouteSpecification>
  </Specifications>
</RoutesSpecification>

XML response

<RoutesResult xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Errors />
  <Status>None</Status>
  <Results>
    <RouteResult>
      <Errors />
      <Status>Success</Status>
      <Route>
        <Distance>18.963006044698957</Distance>
        <Time>1731</Time>
        <RouteLegs>
          <RouteLeg>
            <Distance>18.963006044698957</Distance>
            <Time>1731</Time>
            <Itinerary>
              <Items>
                <RouteItineraryItem>
                  <Distance>0.25476218881730689</Distance>
                  <LatLong>
                    <Latitude>38.9515221118927</Latitude>
                    <Longitude>-77.296746969223022</Longitude>
                  </LatLong>
                  <Text>Depart Windstone Dr toward Windy Knoll Ln</Text>
                  <Time>45</Time>
                  <Warnings>
                    <RouteWarning>
                      <Severity>None</Severity>
                      <Text>Private Road</Text>
                    </RouteWarning>
                  </Warnings>
                  <Hints />
                </RouteItineraryItem>
                <RouteItineraryItem>
                  <Distance>0.76677205122087011</Distance>
                  <LatLong>
                    <Latitude>38.955159187316895</Latitude>
                    <Longitude>-77.296929359436035</Longitude>
                  </LatLong>
                  <Text>Turn right onto VA-675 / Browns Mill Rd</Text>
                  <Time>83</Time>
                  <Warnings />
                  <Hints />
                </RouteItineraryItem>
                <RouteItineraryItem>
                  <Distance>0.75931559691402206</Distance>
                  <LatLong>
                    <Latitude>38.950572609901428</Latitude>
                    <Longitude>-77.28458046913147</Longitude>
                  </LatLong>
                  <Text>Turn left onto VA-702 / Beulah Rd</Text>
                  <Time>107</Time>
                  <Warnings />
                  <Hints />
                </RouteItineraryItem>
                ...
                <RouteItineraryItem>
                  <Distance>0</Distance>
                  <LatLong>
                    <Latitude>38.90882134437561</Latitude>
                    <Longitude>-77.064883410930634</Longitude>
                  </LatLong>
                  <Text>Arrive at Loc_2 on the left</Text>
                  <Time>0</Time>
                  <Warnings />
                  <Hints>
                    <RouteHint>
                      <Type>PreviousIntersection</Type>
                    </RouteHint>
                    <RouteHint>
                      <Type>NextIntersection</Type>
                    </RouteHint>
                  </Hints>
                </RouteItineraryItem>
              </Items>
            </Itinerary>
          </RouteLeg>
        </RouteLegs>
        <Points>
          <LatLong>
            <Latitude>38.951522</Latitude>
            <Longitude>-77.296746</Longitude>
          </LatLong>
          <LatLong>
            <Latitude>38.952852</Latitude>
            <Longitude>-77.297042</Longitude>
          </LatLong>
          <LatLong>
            <Latitude>38.953582</Latitude>
            <Longitude>-77.29695000000001</Longitude>
          </LatLong>
          ...
          <LatLong>
            <Latitude>38.908820999999975</Latitude>
            <Longitude>-77.064883</Longitude>
          </LatLong>
        </Points>
      </Route>
    </RouteResult>
    <RouteResult>
      <Errors />
      <Status>Success</Status>
      <Route>
        <Distance>11.165418953312653</Distance>
        <Time>1163</Time>
        <RouteLegs>
          <RouteLeg>
            <Distance>11.165418953312653</Distance>
            <Time>1163</Time>
            <Itinerary>
              <Items>
                <RouteItineraryItem>
                  <Distance>0.060273005647021392</Distance>
                  <LatLong>
                    <Latitude>38.936732411384583</Latitude>
                    <Longitude>-77.2865492105484</Longitude>
                  </LatLong>
                  <Text>Depart Asoleado Ln toward Lozano Dr</Text>
                  <Time>10</Time>
                  <Warnings />
                  <Hints />
                </RouteItineraryItem>
                <RouteItineraryItem>
                  <Distance>0.50579615048118975</Distance>
                  <LatLong>
                    <Latitude>38.93730103969574</Latitude>
                    <Longitude>-77.2873592376709</Longitude>
                  </LatLong>
                  <Text>Turn right onto Lozano Dr</Text>
                  <Time>93</Time>
                  <Warnings />
                  <Hints />
                </RouteItineraryItem>
                ...
                <RouteItineraryItem>
                  <Distance>0</Distance>
                  <LatLong>
                    <Latitude>38.949450775980949</Latitude>
                    <Longitude>-77.137107253074646</Longitude>
                  </LatLong>
                  <Text>Arrive at Loc_2 on the right</Text>
                  <Time>0</Time>
                  <Warnings />
                  <Hints />
                </RouteItineraryItem>
              </Items>
            </Itinerary>
          </RouteLeg>
        </RouteLegs>
        <Points>
          <LatLong>
            <Latitude>38.936732</Latitude>
            <Longitude>-77.286549</Longitude>
          </LatLong>
          <LatLong>
            <Latitude>38.936941</Latitude>
            <Longitude>-77.286961999999988</Longitude>
          </LatLong>
         ...
          <LatLong>
            <Latitude>38.94945</Latitude>
            <Longitude>-77.137106999999972</Longitude>
          </LatLong>
        </Points>
      </Route>
    </RouteResult>
  </Results>
</RoutesResult>

XML request

The following request uses two routes with two locations in each route. Every location uses with Latitude/Longitude. In this example we defined map size and route color in each route. If map size is defined you will receive map images encoded to base64string. You can also specify map center, zoom level (1-18) and hide stops on a map. For more details see RoutesSpecification.

<RoutesSpecification>
  <Specifications>
    <RouteSpecification>
      <Locations>
        <Location>
          <Name>Loc_1</Name>
          <LatLong>
            <Latitude>38.951594</Latitude>
            <Longitude>-77.29602</Longitude>
          </LatLong>
        </Location>
        <Location>
          <Name>Loc_2</Name>
          <LatLong>
            <Latitude>38.908467</Latitude>
            <Longitude>-77.064874</Longitude>
          </LatLong>
        </Location>
      </Locations>
      <RouteOptions>
        <Culture>en-US</Culture>
        <DistanceUnit>Mile</DistanceUnit>
        <RouteOptimize>MinimizeTime</RouteOptimize>
        <MapSize>
          <Width>400</Width>
          <Height>200</Height>
        </MapSize>
        <RouteColor>
          <A>168</A>
          <R>255</R>
          <G>0</G>
          <B>0</B>
        </RouteColor>
      </RouteOptions>
    </RouteSpecification>
    <RouteSpecification>
      <Locations>
        <Location>
          <Name>Loc_1</Name>
          <LatLong>
            <Latitude>38.934594</Latitude>
            <Longitude>-77.28602</Longitude>
          </LatLong>
        </Location>
        <Location>
          <Name>Loc_2</Name>
          <LatLong>
            <Latitude>38.948467</Latitude>
            <Longitude>-77.136874</Longitude>
          </LatLong>
        </Location>
      </Locations>
      <RouteOptions>
        <Culture>en-US</Culture>
        <DistanceUnit>Mile</DistanceUnit>
        <RouteOptimize>MinimizeTime</RouteOptimize>
        <MapSize>
          <Width>400</Width>
          <Height>200</Height>
        </MapSize>
      </RouteOptions>
    </RouteSpecification>
  </Specifications>
  <RoutesOptions>
    <MapSize>
      <Width>800</Width>
      <Height>600</Height>
    </MapSize>
    <RouteColor>
      <A>178</A>
      <R>1</R>
      <G>168</G>
      <B>234</B>
    </RouteColor>
  </RoutesOptions>
</RoutesSpecification>

XML response

<RoutesResult xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Errors />
  <Status>None</Status>
  <Results>
    <RouteResult>
      <Errors />
      <Status>Success</Status>
      <Route>
        <Distance>18.963006044698957</Distance>
        <Time>1731</Time>
        <RouteLegs>
          <RouteLeg>
            <Distance>18.963006044698957</Distance>
            <Time>1731</Time>
            <Itinerary>
              <Items>
                <RouteItineraryItem>
                  <Distance>0.25476218881730689</Distance>
                  <LatLong>
                    <Latitude>38.9515221118927</Latitude>
                    <Longitude>-77.296746969223022</Longitude>
                  </LatLong>
                  <Text>Depart Windstone Dr toward Windy Knoll Ln</Text>
                  <Time>45</Time>
                  <Warnings>
                    <RouteWarning>
                      <Severity>None</Severity>
                      <Text>Private Road</Text>
                    </RouteWarning>
                  </Warnings>
                  <Hints />
                </RouteItineraryItem>
                <RouteItineraryItem>
                  <Distance>0.76677205122087011</Distance>
                  <LatLong>
                    <Latitude>38.955159187316895</Latitude>
                    <Longitude>-77.296929359436035</Longitude>
                  </LatLong>
                  <Text>Turn right onto VA-675 / Browns Mill Rd</Text>
                  <Time>83</Time>
                  <Warnings />
                  <Hints />
                </RouteItineraryItem>
                ...
                <RouteItineraryItem>
                  <Distance>0</Distance>
                  <LatLong>
                    <Latitude>38.90882134437561</Latitude>
                    <Longitude>-77.064883410930634</Longitude>
                  </LatLong>
                  <Text>Arrive at Loc_2 on the left</Text>
                  <Time>0</Time>
                  <Warnings />
                  <Hints>
                    <RouteHint>
                      <Type>PreviousIntersection</Type>
                    </RouteHint>
                    <RouteHint>
                      <Type>NextIntersection</Type>
                    </RouteHint>
                  </Hints>
                </RouteItineraryItem>
              </Items>
            </Itinerary>
            <Map>iVBORw0KGgoAAAANSUhEUgAAAZAAAADICAMAAADxy0fQAAAAA</Map>
          </RouteLeg>
        </RouteLegs>
        <Points>
          <LatLong>
            <Latitude>38.951522</Latitude>
            <Longitude>-77.296746</Longitude>
          </LatLong>
          <LatLong>
            <Latitude>38.952852</Latitude>
            <Longitude>-77.297042</Longitude>
          </LatLong>
          <LatLong>
            <Latitude>38.953582</Latitude>
            <Longitude>-77.29695000000001</Longitude>
          </LatLong>
          <LatLong>
            <Latitude>38.954181999999996</Latitude>
            <Longitude>-77.296779000000015</Longitude>
          </LatLong>
          ...
          <LatLong>
            <Latitude>38.908820999999975</Latitude>
            <Longitude>-77.064883</Longitude>
          </LatLong>
        </Points>
        <Map>iVBORw0KGgoAAAANSUhEUgAAAZAAAADICAMAAADxy0fQAAAAAXNS...</Map>
      </Route>
    </RouteResult>
    <RouteResult>
      <Errors />
      <Status>Success</Status>
      <Route>
        <Distance>10.62544738725841</Distance>
        <Time>1097</Time>
        <RouteLegs>
          <RouteLeg>
            <Distance>10.62544738725841</Distance>
            <Time>1097</Time>
            <Itinerary>
              <Items>
                <RouteItineraryItem>
                  <Distance>0.54929213393780318</Distance>
                  <LatLong>
                    <Latitude>38.934097141027451</Latitude>
                    <Longitude>-77.286130115389824</Longitude>
                  </LatLong>
                  <Text>Depart Meadowlark Rd toward Brookside Ln</Text>
                  <Time>99</Time>
                  <Warnings />
                  <Hints />
                </RouteItineraryItem>
                <RouteItineraryItem>
                  <Distance>0.58284617831861918</Distance>
                  <LatLong>
                    <Latitude>38.936442732810974</Latitude>
                    <Longitude>-77.277510166168213</Longitude>
                  </LatLong>
                  <Text>Bear right onto VA-675 / Beulah Rd</Text>
                  <Time>97</Time>
                  <Warnings />
                  <Hints />
                </RouteItineraryItem>
                ...
                <RouteItineraryItem>
                  <Distance>0</Distance>
                  <LatLong>
                    <Latitude>38.948457017540932</Latitude>
                    <Longitude>-77.137048244476318</Longitude>
                  </LatLong>
                  <Text>Arrive at Loc_2 on the right</Text>
                  <Time>0</Time>
                  <Warnings />
                  <Hints />
                </RouteItineraryItem>
              </Items>
            </Itinerary>
            <Map>iVBORw0KGgoAAAANSUhEUgAAAZAAAADICAMAAADxy0fQAAAAAXNSR0IArs4c6QAAAARn...</Map>
          </RouteLeg>
        </RouteLegs>
        <Points>
          <LatLong>
            <Latitude>38.934097</Latitude>
            <Longitude>-77.28613</Longitude>
          </LatLong>
          <LatLong>
            <Latitude>38.933851000000004</Latitude>
            <Longitude>-77.28531</Longitude>
          </LatLong>
          ...
          <LatLong>
            <Latitude>38.948456999999983</Latitude>
            <Longitude>-77.137048</Longitude>
          </LatLong>
        </Points>
        <Map>iVBORw0KGgoAAAANSUhEUgAAAZAAAADICAMAAADxy0fQAAAAAXNSR0IArs4c6QAA...</Map>
      </Route>
    </RouteResult>
  </Results>
  <Map>iVBORw0KGgoAAAANSUhEUgAAAyAAAAJYCAMAAACtqHJCAAAAAXNSR0IArs4c6QAAAARnQU1B...</Map>
</RoutesResult>

JSON

To receive response in JSON format you must specify content type text/json or application/json. For example:

...
httpWReq.Method = "POST";
httpWReq.ContentType = "text/json; charset=utf-8";
httpWReq.ContentLength = data.Length;
...

JSON request

The following request uses two routes with two locations in each route.

{
   "Specifications":[
      {
         "Locations":[
            {
               "MatchCode":0,
               "Name":"Loc_1",
               "Delivery":null,
               "Vehicle":null,
               "Description":null,
               "Phone":null,
               "LatLong":{
                  "Latitude":38.951594,
                  "Longitude":-77.29602
               },
               "Address":null,
               "Priority":0,
               "Wait":0,
               "Volume":0,
               "Weight":0,
               "Skids":0,
               "TimeConstraintArrival":"\/Date(-62135596800000)\/",
               "TimeConstraintDeparture":"\/Date(-62135596800000)\/",
               "TimeConstraintArrival2":"\/Date(-62135596800000)\/",
               "TimeConstraintDeparture2":"\/Date(-62135596800000)\/",
               "LocationType":0,
               "CanArriveEarly":true,
               "Distance":0,
               "Time":0
            },
            {
               "MatchCode":0,
               "Name":"Loc_2",
               "Delivery":null,
               "Vehicle":null,
               "Description":null,
               "Phone":null,
               "LatLong":{
                  "Latitude":38.908467,
                  "Longitude":-77.064874
               },
               "Address":null,
               "Priority":0,
               "Wait":0,
               "Volume":0,
               "Weight":0,
               "Skids":0,
               "TimeConstraintArrival":"\/Date(-62135596800000)\/",
               "TimeConstraintDeparture":"\/Date(-62135596800000)\/",
               "TimeConstraintArrival2":"\/Date(-62135596800000)\/",
               "TimeConstraintDeparture2":"\/Date(-62135596800000)\/",
               "LocationType":0,
               "CanArriveEarly":true,
               "Distance":0,
               "Time":0
            }
         ],
         "RouteOptions":{
            "DistanceUnit":0,
            "RouteOptimize":0,
            "Culture":"en-US",
            "MapSize":{
               "Width":400,
               "Height":200
            },
            "RouteColor":{
               "A":168,
               "R":255,
               "G":0,
               "B":0
            },
            "MapCenter":null,
            "HideStops":false,
            "ZoomLevel":0
         }
      },
      {
         "Locations":[
            {
               "MatchCode":0,
               "Name":"Loc_1",
               "Delivery":null,
               "Vehicle":null,
               "Description":null,
               "Phone":null,
               "LatLong":{
                  "Latitude":38.934594,
                  "Longitude":-77.28602
               },
               "Address":null,
               "Priority":0,
               "Wait":0,
               "Volume":0,
               "Weight":0,
               "Skids":0,
               "TimeConstraintArrival":"\/Date(-62135596800000)\/",
               "TimeConstraintDeparture":"\/Date(-62135596800000)\/",
               "TimeConstraintArrival2":"\/Date(-62135596800000)\/",
               "TimeConstraintDeparture2":"\/Date(-62135596800000)\/",
               "LocationType":0,
               "CanArriveEarly":true,
               "Distance":0,
               "Time":0
            },
            {
               "MatchCode":0,
               "Name":"Loc_2",
               "Delivery":null,
               "Vehicle":null,
               "Description":null,
               "Phone":null,
               "LatLong":{
                  "Latitude":38.948467,
                  "Longitude":-77.136874
               },
               "Address":null,
               "Priority":0,
               "Wait":0,
               "Volume":0,
               "Weight":0,
               "Skids":0,
               "TimeConstraintArrival":"\/Date(-62135596800000)\/",
               "TimeConstraintDeparture":"\/Date(-62135596800000)\/",
               "TimeConstraintArrival2":"\/Date(-62135596800000)\/",
               "TimeConstraintDeparture2":"\/Date(-62135596800000)\/",
               "LocationType":0,
               "CanArriveEarly":true,
               "Distance":0,
               "Time":0
            }
         ],
         "RouteOptions":{
            "DistanceUnit":0,
            "RouteOptimize":0,
            "Culture":"en-US",
            "MapSize":{
               "Width":400,
               "Height":200
            },
            "RouteColor":null,
            "MapCenter":null,
            "HideStops":false,
            "ZoomLevel":0
         }
      }
   ],
   "RoutesOptions":{
      "DistanceUnit":0,
      "RouteOptimize":0,
      "Culture":"en-US",
      "MapSize":{
         "Width":800,
         "Height":600
      },
      "RouteColor":{
         "A":178,
         "R":1,
         "G":168,
         "B":234
      },
      "MapCenter":null,
      "HideStops":false,
      "ZoomLevel":0
   }
}

JSON Response

{
   "Results":[
      {
         "Route":{
            "Distance":18.963006044698957,
            "Time":1731,
            "RouteLegs":[
               {
                  "Distance":18.963006044698957,
                  "Time":1731,
                  "Itinerary":{
                     "Items":[
                        {
                           "Distance":0.25476218881730689,
                           "LatLong":{
                              "Latitude":38.9515221118927,
                              "Longitude":-77.296746969223022
                           },
                           "Text":"Depart Windstone Dr toward Windy Knoll Ln",
                           "Time":45,
                           "Warnings":[
                              {
                                 "Severity":0,
                                 "Text":"Private Road"
                              }
                           ],
                           "Hints":[

                           ]
                        },
                        {
                           "Distance":0.76677205122087011,
                           "LatLong":{
                              "Latitude":38.955159187316895,
                              "Longitude":-77.296929359436035
                           },
                           "Text":"Turn right onto VA-675 / Browns Mill Rd",
                           "Time":83,
                           "Warnings":[

                           ],
                           "Hints":[

                           ]
                        },
                        ...
                        {
                           "Distance":0.0,
                           "LatLong":{
                              "Latitude":38.90882134437561,
                              "Longitude":-77.064883410930634
                           },
                           "Text":"Arrive at Loc_2 on the left",
                           "Time":0,
                           "Warnings":[

                           ],
                           "Hints":[
                              {
                                 "Type":0,
                                 "Text":null
                              },
                              {
                                 "Type":1,
                                 "Text":null
                              }
                           ]
                        }
                     ]
                  },
                  "Map":"iVBORw0KGgoAAAANSUhEUgAAAZAAAADICAMAAADxy0f..."
               }
            ],
            "Points":[
               {
                  "Latitude":38.951522,
                  "Longitude":-77.296746
               },
               {
                  "Latitude":38.952852,
                  "Longitude":-77.297042
               },
               ...
               {
                  "Latitude":38.908820999999975,
                  "Longitude":-77.064883
               }
            ],
            "Map":"iVBORw0KGgoAAAANSUhEUgAAAZAAAADI..."
         },
         "Errors":[

         ],
         "Status":1
      },
      {
         "Route":{
            "Distance":10.62544738725841,
            "Time":1097,
            "RouteLegs":[
               {
                  "Distance":10.62544738725841,
                  "Time":1097,
                  "Itinerary":{
                     "Items":[
                        {
                           "Distance":0.54929213393780318,
                           "LatLong":{
                              "Latitude":38.934097141027451,
                              "Longitude":-77.286130115389824
                           },
                           "Text":"Depart Meadowlark Rd toward Brookside Ln",
                           "Time":99,
                           "Warnings":[

                           ],
                           "Hints":[

                           ]
                        },
                        {
                           "Distance":0.58284617831861918,
                           "LatLong":{
                              "Latitude":38.936442732810974,
                              "Longitude":-77.277510166168213
                           },
                           "Text":"Bear right onto VA-675 / Beulah Rd",
                           "Time":97,
                           "Warnings":[

                           ],
                           "Hints":[

                           ]
                        },
                        ...
                        {
                           "Distance":0.0,
                           "LatLong":{
                              "Latitude":38.948457017540932,
                              "Longitude":-77.137048244476318
                           },
                           "Text":"Arrive at Loc_2 on the right",
                           "Time":0,
                           "Warnings":[

                           ],
                           "Hints":[

                           ]
                        }
                     ]
                  },
                  "Map":"iVBORw0KGgoAAAANSUhEUgAAAZAAAADICAMAAADxy0..."
               }
            ],
            "Points":[
               {
                  "Latitude":38.934097,
                  "Longitude":-77.28613
               },
               {
                  "Latitude":38.933851000000004,
                  "Longitude":-77.28531
               },
               {
                  "Latitude":38.933899000000004,
                  "Longitude":-77.285126999999989
               },
               ...
               {
                  "Latitude":38.948456999999983,
                  "Longitude":-77.137048
               }
            ],
            "Map":"iVBORw0KGgoAAAANSUhEU...",
            "Errors":[

            ],
            "Status":0
         }
...

See Also

RouteSpecification
RouteResult