I’ve created a global method, which takes up to eight parameters. The first four are the target address. The optional second four are the address from which you want directions.
This works for US addresses. Any suggestions for improvement would be appreciated, as always.
I hope this is helpful for someone else, as well. I’m using it in a solution for a company that does roofing. The salesperson, installers, inspectors and so on all need to get to the home, without a lot of writing down directions for one another.
I created a form method that offers the user either a map, directions from the office, or directions from the installer (3d party contractor) office, then calls this method with the appropriate parameters.
Enjoy!
address1 = arguments[0];
city1 = arguments[1];
state1 = arguments[2];
zip1 = arguments[3];
if (!arguments[4])
{
urlString = 'http://mapquest.com/maps/map.adp?countrycode=250&country=US&address=';
urlString += '&address=';
urlString += utils.stringReplace(address1, ' ', '+');
urlString += '&city=';
urlString += utils.stringReplace(city1, ' ', '+');
urlString += '&state=';
urlString += utils.stringReplace(state1, ' ', '+');
urlString += '&zip=';
urlString += utils.stringReplace(zip1, ' ', '+');
urlString += '&submit.x=33&submit.y=15&addtohistory='
}
else
{
address2 = arguments[4];
city2 = arguments[5];
state2 = arguments[6];
zip2 = arguments[7];
urlString = 'http://www.mapquest.com/directions/main.adp?go=1&do=nw&un=m&cl=EN&ct=NA&rsres=1&1y=US&';
urlString += '1a=';
urlString += utils.stringReplace(address2, ' ', '+');
urlString += '&1c=';
urlString += utils.stringReplace(city2, ' ', '+');
urlString += '&1s=';
urlString += utils.stringReplace(state2, ' ', '+');
urlString += '&1z=';
urlString += utils.stringReplace(zip2, ' ', '+');
urlString += '&1ah=';
urlString += '&2y=US';
urlString += '&2a=';
urlString += utils.stringReplace(address1, ' ', '+');
urlString += '&2c=';
urlString += utils.stringReplace(city1, ' ', '+');
urlString += '&2s=';
urlString += utils.stringReplace(state1, ' ', '+');
urlString += '&2z';
urlString += utils.stringReplace(zip1, ' ', '+');
urlString += '2ah='
}
application.showURL(urlString);