Route Calculation /distance

Route calculation between two points. It is possible to specify points through which the route must pass and through which it should not pass.

Request Schema

https://api.visicom.ua/data-api/5.0/core/distance.json?[origin][&destination][&waypoints][&locks][&mode][&accuracy][&key][&callback]

Request Parameters

ParameterDescription
origin|oStarting point. Object identifier or latitude and longitude in the form of lng,lat. You can also specify geometry in WKT format with no more than 250 vertices.
destination|dFinish point. Object identifier or latitude and longitude in the form of lng,lat. You can also specify geometry in WKT format with no more than 250 vertices.
waypoints|wList of intermediate points (no more than 25). A point is described by an object identifier or latitude and longitude in the form of lng,lat or in WKT format. The , symbol is a separator for points in the list when using identifiers. The | symbol is a separator for points in the list when using latitude and longitude.
locks|lArray of passage blocking coordinates. Blocking is described by an object identifier or latitude and longitude in the form of lng,lat. For road passages, it prohibits route planning at the blocking location. Makes sense only for driving and driving-shortest calculation modes. The , symbol is a separator for points in the list when using identifiers. The | symbol is a separator for points in the list when using latitude and longitude.
mode|mRoute calculation mode. Can take values driving (optimal route on roads), driving-shortest (shortest route on roads), direct (straight-line distance). By default, calculation is performed in driving mode.
geometry|gParameter specifies whether to return route geometry in the response. Can take values no (do not return), path (return route geometry between two points as LineString). Default value is no - geometry is not returned.
accuracy|aGeneralization of route geometry in meters. Default is 10 m.
keyAuthorization key.
callbackFunction name for JSONP request to the server.

Request Examples

https://api.visicom.ua/data-api/5.0/core/distance.json?origin=30.42612,50.45111&destination=30.44946,50.45682&key=YOUR_API_KEY
https://api.visicom.ua/data-api/5.0/core/distance.json?origin=POIA1KIGKN&destination=30.52239,50.44777&waypoints=30.54173,50.44497&geometry=path&key=YOUR_API_KEY

Response

The structure of the distance request response depends on the value of the geometry parameter.

geometry = no

{
    "distance": 1234
}

An object with one field distance — route length in meters.

geometry = path

{
    "type": "Feature",
    "properties": {
        "distance": 3038,
        "origin": {
            "type": "Point",
            "coordinates": [
                30.42615,
                50.45119
            ]
        },
        "destination": {
            "type": "Point",
            "coordinates": [
                30.44679,
                50.45716
            ]
        }
    },
    "geometry": {
        "type": "LineString",
        "coordinates": [
            [
                30.42615,
                50.45119
            ],
            [
                30.42749,
                50.45097
            ],
            [
                30.42674,
                50.44899
            ],
            [
                30.43016,
                50.44846
            ],
            [
                30.43318,
                50.44802
            ],
            [
                30.43347,
                50.44879
            ],
            [
                30.4339,
                50.44997
            ],
            [
                30.43456,
                50.45171
            ],
            [
                30.43622,
                50.45597
            ],
            [
                30.44134,
                50.45515
            ],
            [
                30.4464,
                50.45433
            ],
            [
                30.44656,
                50.45423
            ],
            [
                30.44661,
                50.45415
            ],
            [
                30.44663,
                50.45409
            ],
            [
                30.44657,
                50.4539
            ],
            [
                30.44643,
                50.45351
            ],
            [
                30.44635,
                50.45342
            ],
            [
                30.44625,
                50.45338
            ],
            [
                30.44614,
                50.45335
            ],
            [
                30.44591,
                50.45333
            ],
            [
                30.44579,
                50.45334
            ],
            [
                30.44569,
                50.45338
            ],
            [
                30.44562,
                50.45344
            ],
            [
                30.44553,
                50.45365
            ],
            [
                30.44609,
                50.4551
            ],
            [
                30.4463,
                50.4557
            ],
            [
                30.44651,
                50.45627
            ],
            [
                30.44679,
                50.45716
            ]
        ]
    },
    "bbox": [
        30.42615,
        50.44802,
        30.44679,
        50.45716
    ]
}

The response returns GeoJSON objects of type Feature. The geometry field contains an object of type LineString. The properties field contains a JSON object with fields:

  • origin type Point — starting point
  • destination type Point — finish point
  • distance - route length in meters

If the route could not be calculated, an empty object {} is returned.

Demo

You can move the points.