Geocode

Use the following URL templates to get latitude and longitude coordinates for a location by specifying values such as a postal code, and street address.

When you make a request by using one of the following URL templates, the response returns one or more Location resources that contain location information associated with the sent data parameter values. The location information for each resource includes latitude and longitude coordinates. For more information about the Location resource, see Location Data. You can also view the example URL and response values in the Examples section.

Use the followith URL template to geocode address. Request type must be POST for both XML and JSON format.

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

You must login to get a key.

For more details about request parameters see GeocodeSpecification.

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 addresses.

<GeocodeSpecification>
  <IsNeedMatchCode>true</IsNeedMatchCode>
  <Addresses>
    <Address>
      <Street>6718 Whittier Avenue</Street>
      <City>McLean</City>
      <State>VA</State>
      <PostalCode>22101</PostalCode>
      <Country>US</Country>
    </Address>
    <Address>
      <Street>1450 Old Chain Bridge Road</Street>
      <City>McLean</City>
      <State>VA</State>
      <PostalCode>22101</PostalCode>
      <Country>US</Country>
    </Address>
  </Addresses>
</GeocodeSpecification>

XML response

<GeocodeResult xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Errors />
  <Status>Success</Status>
  <Items>
    <GeocodeItem>
      <Address>
        <Street>6718 Whittier Avenue</Street>
        <City>McLean</City>
        <State>VA</State>
        <PostalCode>22101</PostalCode>
        <Country>US</Country>
      </Address>
      <Locations>
        <Location>
          <MatchCode>Exact</MatchCode>
          <Delivery />
          <Vehicle />
          <Description />
          <Phone />
          <LatLong>
            <Latitude>38.931594</Latitude>
            <Longitude>-77.17602</Longitude>
          </LatLong>
          <Address>
            <Street>6718 Whittier Avenue</Street>
            <City>McLean</City>
            <State>VA</State>
            <PostalCode>22101</PostalCode>
            <Country>US</Country>
          </Address>
          <CanArriveEarly>false</CanArriveEarly>
        </Location>
      </Locations>
    </GeocodeItem>
    <GeocodeItem>
      <Address>
        <Street>1450 Old Chain Bridge Road</Street>
        <City>McLean</City>
        <State>VA</State>
        <PostalCode>22101</PostalCode>
        <Country>US</Country>
      </Address>
      <Locations>
        <Location>
          <MatchCode>Good</MatchCode>
          <Delivery />
          <Vehicle />
          <Description />
          <Phone />
          <LatLong>
            <Latitude>38.936709109693766</Latitude>
            <Longitude>-77.175782695412636</Longitude>
          </LatLong>
          <Address>
            <Street>Old Chain Bridge Rd</Street>
            <City>Mc Lean</City>
            <State>VA</State>
            <PostalCode>22101</PostalCode>
            <Country>US</Country>
          </Address>
          <CanArriveEarly>false</CanArriveEarly>
        </Location>
        <Location>
          <MatchCode>Good</MatchCode>
          <Delivery />
          <Vehicle />
          <Description />
          <Phone />
          <LatLong>
            <Latitude>38.936709109693766</Latitude>
            <Longitude>-77.175782695412636</Longitude>
          </LatLong>
          <Address>
            <Street>1450 Old Chain Bridge Road</Street>
            <City>McLean</City>
            <State>VA</State>
            <PostalCode>22101</PostalCode>
            <Country>US</Country>
          </Address>
          <CanArriveEarly>false</CanArriveEarly>
        </Location>
      </Locations>
    </GeocodeItem>
  </Items>
</GeocodeResult>

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 addresses.

{
    "IsNeedMatchCode":false,
    "Addresses":
    [
        {
            "Street":"6718 Whittier Ave",
            "City":"McLean",
            "State":"VA",
            "PostalCode":"22102",
            "Country":"US"
        },
        {
            "Street":"1450 Old Chain Bridge Road",
            "City":"McLean",
            "State":"VA",
            "PostalCode":"22101",
            "Country":"US"
        }
    ]
}

JSON Response

{
   "Items":[
      {
         "Address":{
            "Street":"6718 Whittier Ave",
            "City":"McLean",
            "State":"VA",
            "PostalCode":"22102",
            "Country":"US"
         },
         "Locations":[
            {
               "MatchCode":3,
               "Name":null,
               "Delivery":"",
               "Vehicle":"",
               "Description":"",
               "Phone":"",
               "LatLong":{
                  "Latitude":38.9315864,
                  "Longitude":-77.1760081
               },
               "Address":{
                  "Street":"6718 Whittier Ave",
                  "City":"McLean",
                  "State":"VA",
                  "PostalCode":"22102",
                  "Country":"US"
               },
               "Priority":0,
               "Wait":0,
               "Volume":0.0,
               "Weight":0.0,
               "Skids":0,
               "TimeConstraintArrival":"0001-01-01T00:00:00",
               "TimeConstraintDeparture":"0001-01-01T00:00:00",
               "TimeConstraintArrival2":"0001-01-01T00:00:00",
               "TimeConstraintDeparture2":"0001-01-01T00:00:00",
               "LocationType":0,
               "CanArriveEarly":false,
               "Distance":0.0,
               "Time":0
            }
         ]
      },
      {
         "Address":{
            "Street":"1450 Old Chain Bridge Road",
            "City":"McLean",
            "State":"VA",
            "PostalCode":"22101",
            "Country":"US"
         },
         "Locations":[
            {
               "MatchCode":3,
               "Name":null,
               "Delivery":"",
               "Vehicle":"",
               "Description":"",
               "Phone":"",
               "LatLong":{
                  "Latitude":38.936709109693766,
                  "Longitude":-77.175782695412636
               },
               "Address":{
                  "Street":"Old Chain Bridge Rd",
                  "City":"Mc Lean",
                  "State":"VA",
                  "PostalCode":"22101",
                  "Country":"US"
               },
               "Priority":0,
               "Wait":0,
               "Volume":0.0,
               "Weight":0.0,
               "Skids":0,
               "TimeConstraintArrival":"0001-01-01T00:00:00",
               "TimeConstraintDeparture":"0001-01-01T00:00:00",
               "TimeConstraintArrival2":"0001-01-01T00:00:00",
               "TimeConstraintDeparture2":"0001-01-01T00:00:00",
               "LocationType":0,
               "CanArriveEarly":false,
               "Distance":0.0,
               "Time":0
            },
            {
               "MatchCode":3,
               "Name":null,
               "Delivery":"",
               "Vehicle":"",
               "Description":"",
               "Phone":"",
               "LatLong":{
                  "Latitude":38.936709109693766,
                  "Longitude":-77.175782695412636
               },
               "Address":{
                  "Street":"1450 Old Chain Bridge Road",
                  "City":"McLean",
                  "State":"VA",
                  "PostalCode":"22101",
                  "Country":"US"
               },
               "Priority":0,
               "Wait":0,
               "Volume":0.0,
               "Weight":0.0,
               "Skids":0,
               "TimeConstraintArrival":"0001-01-01T00:00:00",
               "TimeConstraintDeparture":"0001-01-01T00:00:00",
               "TimeConstraintArrival2":"0001-01-01T00:00:00",
               "TimeConstraintDeparture2":"0001-01-01T00:00:00",
               "LocationType":0,
               "CanArriveEarly":false,
               "Distance":0.0,
               "Time":0
            }
         ]
      }
   ],
   "Errors":[

   ],
   "Status":1
}

See Also

Geocode Specification