API

LocationBox API

Distance Matrix

Distance Matrix Service gives distances between locations based on criterias which you can find below.

A Distance Matrix service request must look like this:

http://www.locationbox.com.tr/locationbox/services?Key=key&Cmd=DistanceMatrix&Typ=output_format&Criteria=criteria
&Route=route&Cons=constraints&Positions=positions


Request Parameters


Key: LocationBox user key. (Register for user key)
Cmd: LocationBox service name. (Rota)
Typ: Response format. (XML or JSON)
Criteria (optional): Calculate the shortest (SHORT) or fastest (FAST) route. (Default: FAST)
Route: Default value is 0. If value is 0, you get air distance between positions. If value is 1, you get route distance between positions.
Cons (optional): Specify the route constraints. (Toll roads, ferry etc.)

Route Constraints
FERIBOT -- Avoid ferry.
OTOYOL -- Avoid toll roads.
KAMYON -- Avoid no truck roads.

Positions: Additional points to the route to pass through. The points are specified in pointname/latitude/longitude format and separated by commas.
Route calculation requires at least two points (start point and end point).

Response Parameters


XML Response

Distance Matrix service response returns in XML format when the Typ parameter is set as "XML".

Below is an example for a Distance Matrix service request which is expected to return a response in XML format .

http://www.locationbox.com.tr/locationbox/services?Key=key&Cmd=DistanceMatrix&Typ=XML&Criteria=FAST
&Cons=KAMYON,FERIBOT&
&Route=0&Positions=PointA/41.1/29.1,PointB/40.984818/29.083635,PointC/40.948784/29.170496


The response will be as following:

<response>
 <transactionid>LBS_212</transactionid>
 <status>0</status>
 <errno />
 <errdesc />
 <distances>
  <distance>
   <frompoint>
    <name>PointA</name>
    <type>0</type>
    <latitude>41.1</latitude>
    <longitude>29.1</longitude>
   </frompoint>
   <topoint>
    <name>PointB</name>
    <type>0</type>
    <latitude>40.984818</latitude>
    <longitude>29.083635</longitude>
   </topoint>
  <distance>12865</distance>
  </distance>
  <distance>
   <frompoint>
    <name>PointA</name>
    <type>0</type>
    <latitude>41.1</latitude>
    <longitude>29.1</longitude>
   </frompoint>
   <topoint>
    <name>PointC</name>
    <type>0</type>
    <latitude>40.948784</latitude>
    <longitude>29.170496</longitude>
   </topoint>
  <distance>17809</distance>
  </distance>

   ...

 </distances>
</response>

JSON Response

Distance Matrix service response returns in JSON format when the Typ parameter is set as "JSON".

Below is an example for a Distance Matrix service request which is expected to return a response in JSON format .

http://www.locationbox.com.tr/locationbox/services?Key=key&Cmd=DistanceMatrix&Typ=JSON&Criteria=FAST
&Cons=KAMYON,FERIBOT&
&Route=0&Positions=PointA/41.1/29.1,PointB/40.984818/29.083635,PointC/40.948784/29.170496


The response will be as following:

{ "transactionid": "LBS_46154", "status": 0, "distances": [ { "frompoint": { "name": "PointA", "type": 0, "latitude": 41.1, "longitude": 29.1 }, "topoint": { "name": "PointB", "type": 0, "latitude": 40.984818, "longitude": 29.083635 }, "distance": 12865 }, { "frompoint": { "name": "PointA", "type": 0, "latitude": 41.1, "longitude": 29.1 }, "topoint": { "name": "PointC", "type": 0, "latitude": 40.948784, "longitude": 29.170496 }, "distance": 17809 }
...
] }


transactionid: The id of response given by LocationBox Service. Every response can be tracked using transactionid when necessary.
status: Response format. (XML or JSON)

Status Codes
0 -- Success
1 -- Fail

errno: Error code
errdesc: Error definition

Error Codes
10001 Error processing your request. Please try again soon.
Cmd parameter is misspelled/not found.
10011 Error processing your request. Please check the Cmd parameter.
Cmd is not specified.
10012 Error processing your request. Please check the Key parameter.
Key is not specified.
10013 Error processing your request. Please check the Key parameter.
Key is invalid.
20012 No data found.