I was wondering if there are plans to add lets say a getDirections function to
be implemented for each provider.
my thoughts so far, with heavy influence from google, is having an options
object example below
var opt = {
map: true, //whether to display the polyline on the map
dirPnl: "divId", //div to hold the textual directions
dOptions: {
locale: "", //localisation
travelMode: "Driving", //weather driving or walking directions
avoidHighways: true,
getPolyline: true, //weather the function should return a polyline,
would be true if you wanted to handle the display yourself
getSteps: true, //if rather than automaticaly sending the step by sted
directions to the div, you would rather handle it yourself
preserveViewport: true //the map should not be panned after request nad
rendering
},
wayPoints: {
//An array of
[{ //lat lon pairs
lat,
lon
},
//or address pairs
{
address1,
address2
}]
}
}
//google implementation example
getDirections: function (opt) {
var map = this.maps[this.api];
var directions;
var retObj = {};
if (opt.map) {
if (opt.dirPnl !== "") {
directions = new GDirections(map, opt.dirPnl);
} else {
directions = new GDirections(map);
}
} else {
directions = new GDirections();
}
if (opt.dOptions.travelMode == "Driving") {
//set to native
opt.dOptions.travelMode = "G_TRAVEL_MODE_DRIVING";
}
GEvent.addListener(
directions, ''error'', function () {
console.log(directions.getStatus().code);
});
directions.loadFromWaypoints(opt.wayPoints, opt.dOptions);
//return an object with the status of the request, driving or walking
distance, the polylines
if (directions.getStatus().code == 200) {
retObj.error = false;
retObj.distance = directions.getDistance().meters;
if (opt.dOptions.getPolyline) {
retObj.polyLine = getPolyline();
}
return retObj;
} else {
retObj.error = true;
return retObj;
}
}
This has not been tested, I would like to know whether this would be in
accordance with the standards
expected and if it is something that people would like implemented in
mapstraction.
Any input is appreciated
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/201469229/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100304/23280200/attachment.htm>