Driving Direction
You can calculate directions by using the AGDirections object. The AGDirections object requests and receives direction results using given origin and destination in AGDirection.load(). The AGDirections object also supports multi-part directions using a series of waypoints. Directions may be displayed as either a polyline drawing the route on a map.
To use directions in the API, create an object of type AGDirections and pass AGMap for draw routing on map and/or
<div> to receive and display results.
Request Directions
var oDirection = new AGDirections(agmap,div);
oDirection.load(origin,destination);
For via points
var oDirection = new AGDirections(agmap,div);
oDirection.loadFromWayPoints(arrCoordWayPoints); //arrCoordWayPoints = origin, via point , distination.
//it will load in map and panel as well as.
Another services of this class AGDirections is to get route points. To get this you have to keep null in both arguments in AGDirections(). Now load() or loadFromWayPoints() are requested to give route points. When direction is loaded the it will fire a onload event and ready to searve route and so on.
Request Directions
var oDirection = new AGDirections(null,null);
oDirection.load(origin,destination);
AGEvent.addListener(oDirection, "onload", directionloadhandler);
....
function directionloadhandler()
{
var arrCoords = oDirection.getVertices();
var oLine = new AGPolyline(arrCoords);
agmap.addOverlay(oLine);
//other way
var Polyline = oDirection.getPolyline();
agmap.addOverlay(Polyline);
}
//as well as you can get distance boundingbox.
Classes