Click or drag to resize

Telogis.GeoBase.Routing.Direction

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Direction Class

A wrapper class to be filled server-side, representing a single instruction in a Routing.Route.

Functions
NameDescription
getCompassDirection ()

Gets the compass direction that the calling Routing.Direction will send the driver in.

JavaScript
// Create a route, then..
var list = 'Compass directions on departure are:\n\n';///
myRoute.getDirections (function (result) {
    var count = 1;
    for (var i = 0; i < result.getLength (); i++) {
        list +=  'Direction '+ count + ': ' + result.getDirection(i).getCompassDirection() + '\n';
        count++;
    } alert (list);
});
Returns

Number - The direction's compass direction as a Routing.Direction.CompassDirection.

getDistance (String units)

Gets the distance covered by traveling from this Routing.Direction to the next, i.e. the distance it instructs one to travel.

JavaScript
// Create a route, then..
var list = 'Distance from direction to next direction is:\n\n';
var DistanceUnit = Telogis.GeoBase.DistanceUnit;

myRoute.getDirections (function (result) {
    var count = 1;
    for (var i = 0; i < result.getLength (); i++){
        var x = result.getDirection(i).getDistance(DistanceUnit.MILES);
        if (x == 0)    {
            list +=  count + ': Distance unavailable\n';
        } else {;
            list +=  count + ': ' +  x  + ' miles\n';
        }
        count++;
    } alert (list);
});
Arguments
  • (Optional) units (String) - The DistanceUnit code describing the units to return the direction's distance in. Defaults to DistanceUnit.MILES.

Returns

Number - The distance of the direction, in the specified Routing.Direction.getDistance.units, or zero if none was available.

getHeading ()

Gets the clockwise angle from due north that the calling Routing.Direction will send the driver in.

JavaScript
// Create a route, then..
var list = 'Direction headings (headings on departure) are:\n\n';
myRoute.getDirections (function (result) {
    var count = 1;
    for (var i = 0; i < result.getLength (); i++){
        var x = result.getDirection(i).getHeading();
        if (x == 0)    {
            list +=  'Heading unavailable\n';
        } else {;
            list +=  'Direction '+ count + ' heading: ' +  x  + ' degrees\n';
        }
        count++;
    } alert (list);
});
Returns

Number - The direction's heading, in degrees, or zero if none was available.

getLocation ()

The latitude-longitude coordinates describing the location that the Routing.Direction occurs at.

JavaScript
// Create a route, then..
var list = 'Directions locations (LatLon) are:\n\n';
myRoute.getDirections (function (result) {
    var count = 1;
    for (var i = 0; i < result.getLength (); i++) {
        list +=  'Direction '+ count + ' location: ' + result.getDirection(i).getLocation() + '\n';
        count++;
    } alert (list);
});
Returns

LatLon - The location of the direction, or null if none was available.

getNotes ()

Gets a list of any noteworthy components of the calling Routing.Direction.

JavaScript
// Create a route, then..
var list = 'Directions notes:\n\n';
myRoute.getDirections (function (result) {
    var count = 1;
    for (var i = 0; i < result.getLength (); i++) {
        var myNote = result.getDirection(i).getNotes();
        if (myNote != "") {
        list +=  'Note for direction '+ count + ': ' + result.getDirection(i).getNotes() + '\n';
        } count++;
    } alert (list);
});
Returns

Array - An array of Routing.DrivingNotes, each describing some important aspect of the routing direction. If no such notes are available, an empty array is returned. Changing the returned array will modify the direction.

getPoints ()

Gets an array of latitude-longitude coordinates describing a path that represents the Routing.Direction, which can be plotted on a map layer to display it.

JavaScript
// Create a route, then..
var list = 'Directions points are:\n\n';
myRoute.getDirections (function (result) {
    var count = 1;
    for (var i = 0; i < result.getLength (); i++) {
        list +=  'Points describing direction ' + count + ': ' + result.getDirection(i).getPoints() + '\n';
        count++;
    } alert (list);
});
Returns

Array - The list of LatLons representing the direction's path.

getStreet ()

Gets the name of the street that the Routing.Direction will put the driver onto.

JavaScript
// Create a route, then..
myRoute.getDirections (function (result) {
    var count = 1;
    var list = '';
    for (var i = 0; i < result.getLength (); i++) {
        list +=  'The street that follows direction ' + count + ' is: ' + result.getDirection(i).getStreet() + '\n';
        count++;
    } alert (list);
});
Returns

String - The direction's street, or '' if none was available.

getTime ()

Gets the amount of time taken to drive from the calling Routing.Direction to the next.

JavaScript
// Create a route, then..
myRoute.getDirections (function (result) {
    var count = 1;
    var list = '';
    for (var i = 0; i < result.getLength (); i++) {
        list +=  'Drive time from direction '+ count +' to the next is: ' + result.getDirection(i).getTime() + ' seconds\n';
        count++;
    } alert (list);
});
Returns

Number - The duration of the direction, in seconds, or zero if none was available.

isArrival ()

Tests whether the calling Routing.Direction indicates an arrival at a Routing.RouteStop.

JavaScript
// Create a route, then..
myRoute.getDirections (function (result) {
    var count = 1;
    var list = '';
    for (var i = 0; i < result.getLength (); i++) {
        var check = result.getDirection(i).isArrival();
        if (check) {
            list +=  '- Direction ' + count + ' is the last direction before arriving at the routestop on ' +
            result.getDirection(i).getStreet() + ' (direction instruction: ' + result.getDirection(i).toString() + ')\n';
        } count++;
    } alert (list);
}, function (error) {alert(error)});
Returns

Boolean - True if the direction is an arrival at a stop; false otherwise.

isDeparture ()

Tests whether the calling Routing.Direction indicates a departure from a Routing.RouteStop.

JavaScript
// Create a route, then..
myRoute.getDirections (function (result) {
    var count = 1;
    var list = '';
    for (var i = 0; i < result.getLength (); i++) {
        var check = result.getDirection(i).isDeparture();
        if (check) {
            list +=  'Direction ' + count + ' is a departure from a routestop (' +
                result.getDirection(i).toString() + ')\n';
        } count++;
    } alert (list);
});
Returns

Boolean - True if the direction is a departure from a stop; false otherwise.

toString ()

Gets driving instructions for the movement the calling object represents.

JavaScript
// Create a route, then..
var list = 'Directions instructions are:\n\n';
myRoute.getDirections (function (result) {
    var count = 1;
    for (var i = 0; i < result.getLength (); i++) {
        list +=  'Direction '+ count + ': ' + result.getDirection(i).toString() + '\n';
        count++;
    } alert (list);
});
Returns

String - The instructions for the calling Routing.Direction.

Properties
NameTypeDescription
dirRouting.DrivingEvent

a that contains the information about the Routing.Direction that was returned from the server.