Telogis.GeoBase.Routing.Directions |
A representation of a driving route through a number of stops. This is a wrapper class to be filled server-side.
Name | Description |
---|---|
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); };
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 ); 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 ); 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 ); 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 ); 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 ); String - Instructions for following these directions. |