
var reasons=[];reasons[G_GEO_SUCCESS]="Success";reasons[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";reasons[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";reasons[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";reasons[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";reasons[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";reasons[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";Mapstraction.prototype.getRoute=function(points,callback){if(this.loaded[this.api]==false){myself=this;this.onload[this.api].push(function(){myself.getRoute(points,callback);});return;}
var map=this.maps[this.api];switch(this.api){case'google':directions=new GDirections();GEvent.addListener(directions,"error",function(){alert("Error: "+reasons[directions.getStatus().code]);});GEvent.addListener(directions,"load",function(){gpolyline=directions.getPolyline();var points=new Array();for(var i=0;i<gpolyline.getVertexCount();i++){point=new LatLonPoint();point.fromGoogle(gpolyline.getVertex(i));points.push(point);}
callback(new Polyline(points));});var waypoints=new Array();;for(var i=0;i<points.length;i++)
waypoints.push(points[i].toGoogle().toUrlValue(6));directions.loadFromWaypoints(waypoints,{getPolyline:true});break;case'yahoo':case'openstreetmap':case'microsoft':case'openlayers':case'multimap':case'mapquest':case'map24':alert(this.api+' not supported by Mapstraction.getRoute');break;}}