Click or drag to resize

Telogis.GeoBase.Routing.Directions

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

A representation of a driving route through a number of stops. This is a wrapper class to be filled server-side.

Functions
NameDescription
getDirection (Number index)

Returns the Routing.Direction object at the given index.

JavaScript
//... create a route (myRoute), then:
var units = 'Metric'; // Also accepts 'ImperialFeet' and 'ImperialYards'
var culture = 'en-US';
var list = 'Direction instructions for this route:\n\n'

// Create a Directions object containing instructions
myRoute.getDirections(function (result) {
    var count = 1;
        for (i = 0; i < result.getLength(); i++) {
            // Loop through, compiling directions at each index
            list +=  count + ': ' + result.getDirection(i).toString() + '\n';
            count++
        }
    }, function (error) {alert(error)}, units, culture
);

//document.onclick = myTestFunction; // test trigger
function myTestFunction() {
    alert (list);
};
Arguments
  • index (Number) - The index of the direction to return.

Returns

Routing.Direction - The direction with the given index.

getLength ()

Gets the number of directions the Routing.Directions object contains.

JavaScript
//... create a route (myRoute), then:
var units = 'Metric'; // Also accepts 'ImperialFeet' and 'ImperialYards'
var culture = 'en-US';

// Create a Directions object containing instructions
myRoute.getDirections(function (result) {
    alert('There are ' + result.getLength() + ' directions in this object.')
    }, function (error) {alert(error)}, units, culture
);
Returns

Number - The number of individual Routing.Directions.

getPoints ()

Returns the raw coordinate data representing the path corresponding to the route.

JavaScript
//... create a route (myRoute), then:
var units = 'Metric'; // Also accepts 'ImperialFeet' and 'ImperialYards'
var culture = 'en-US';

// Create a Directions object containing instructions
myRoute.getDirections(function (result) {
        alert (result.getPoints())
    }, function (error) {alert(error)}, units, culture
);
Returns

Array - The coordinate directions, as an array of LatLons.

getTotalDistance ()

Returns the total distance of the route.

JavaScript
//... create a route (myRoute), then:
var units = 'Metric'; // Also accepts 'ImperialFeet' and 'ImperialYards'
var culture = 'en-US';

// Create a Directions object containing instructions
myRoute.getDirections(function (result) {
        // Metric returns meters. Use Telogis.GeoBase.MathUtil.convertUnits
        // to quickly convert distance units
        var converted = Telogis.GeoBase.MathUtil.convertUnits(
            result.getTotalDistance(), // Get total distance
            Telogis.GeoBase.DistanceUnit.METERS, // From unit
            Telogis.GeoBase.DistanceUnit.MILES // To unit
        ); alert ('Route distance is ' + converted + ' miles')
    }, function (error) {alert(error)}, units, culture
);
Returns

Number - The total distance of the route in the specified distance unit.

getTotalTime ()

Returns the estimated total duration of the route.

JavaScript
//... create a route (myRoute), then:
var units = 'Metric'; // Also accepts 'ImperialFeet' and 'ImperialYards'
var culture = 'en-US';

// Create a Directions object containing instructions
myRoute.getDirections(function (result) {
        alert ('Route duration (estimated) is ' + result.getTotalTime())
    }, function (error) {alert(error)}, units, culture
);
Returns

String - The sum of the estimated time between all stops on the route as an object with hours, minutes and seconds properties.

toString ()

Gets string instructions for following all the individual directions in the calling object.

JavaScript
//... create a route (myRoute), then:
var units = 'Metric'; // Also accepts 'ImperialFeet' and 'ImperialYards'
var culture = 'en-US';

// Create a Directions object containing instructions
myRoute.getDirections(function (result) {
    alert('Instructions:\n\n' + result.toString())
    }, function (error) {alert(error)}, units, culture
);
Returns

String - Instructions for following these directions.