View Single Post
garymm
Guest
 
Posts: n/a

For starters, I have very limited experience with JavaScript. That out of the way, I want to modify the phonebook widget so that when I click on an address, I get directions to it rather than a map of it. The pertinent section of PhoneBook.js (or at least this is the only thing that I think is pertinent but I have no idea how to use javascript) follows (can be accessed via the "show package contents" on the PhoneBook widget file in Library/Widgets):

var mapURL = "http://www.mapquest.com/maps/map.adp?country=us&address=";

mapURL += URLEncode( singleResult.address );
mapURL += "&city=";
mapURL += URLEncode( singleResult.city );
mapURL += "&state=";
mapURL += URLEncode( singleResult.state );
mapURL += "&zip=";
mapURL += URLEncode( singleResult.zip );

addressSpansContainer.setAttribute("maplink", mapURL );
addressSpansContainer.onclick = function(event)
{
if( window.widget )
widget.openURL(this.getAttribute("maplink"));
}

Here are the mapquest guidelines for creating a link to directions (instead of a map): link

I can figure out how to simply enter my home address into the base URL and have it permanently stored in the PhoneBook.js, but what I really want is a way to make it check my address from my card in Address Book. Is there a way to do this with JavaScript or at all?

Thanks for the help. I will definitely share the edited widget.
QUOTE Thanks