10.4: Replace the phone book widget's mapping service

Apr 29, '05 09:01:00PM

Contributed by: Hes Nikke

Tiger only hintMapquest is an aging mapping system and doesn't fit in with the new shinyness in Tiger. Thats why I made the phone book widget use Google Maps instead.

  1. In the Finder, go to /Library/Widgets
  2. Control-click on Phone Book.wdgt, and choose Show Package Contents from the pop-up menu
  3. Duplicate PhoneBook.js so that you have a back up -- just in case.
  4. Open PhoneBook.js in your favorite Text Editor (I used BBEdit).
  5. Find the following block, which begins on line 802:
    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 );
    
  6. Replace that block with the following block:
    var mapURL = "http://maps.google.com/maps?q=";
    
    mapURL += URLEncode( singleResult.address );
    mapURL += "+";
    mapURL += URLEncode( singleResult.zip );
    mapURL += "&hl=en";
    
  7. Save changes to the file and quit the editor.
Now open Dashboard and reload the Phonebook widget by hitting Command-R. Now whenever you click on an address in the phone book, you'll go to Google maps rather than Mapquest.

[robg adds: I received a similar hint submission from Anonymous, and the only difference was their code for the replacement section. Their code was:
var mapURL = "http://maps.google.com/maps?q=";

mapURL += URLEncode( singleResult.address );
mapURL += "+";
mapURL += URLEncode( singleResult.city );
mapURL += "+";
mapURL += URLEncode( singleResult.state );
mapURL += "+";
mapURL += URLEncode( singleResult.zip );
Since I don't have Tiger with me on the road, I can't test either version right now -- so take your pick, and use the one that works the best!]

Comments (35)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050424065456133