Use Google Maps with People widget

In late December, I described how to use Google Maps with the Address Book widget. Then a few weeks later, Apple goes off and introduces the People widget, which looks up people you enter via an internet White Pages search. (The People widget is part of the OS X 10.4.4 update.) After looking up a person, you can click on their address to be taken to a map showing where he or she lives. I was hoping Apple would use Google’s Maps out of the box, but no such luck—this widget, too, relies on MapQuest.

However, it didn’t take the Macosxhints.com community very long to come up with a fix. Reader Maxwell Bates sent in a solution less than a week later. So if you’d prefer to use Google’s classy maps with the new People widget, here’s what you need to do. Note that you will not need to use the Terminal for this hint at all. If you’re comfortable using TextEdit, you’ve got the required skills.

The first step is to create a copy of the People widget in your user’s Widgets folder, as described in this article. Basically, just drag the People widget from the top-level Library/Widgets folder into your user folder /Library/Widgets (create the folder if necessary) to make a copy of the widget. Your version of the People widget will be more than just a backup. Dashboard will now use this copy, thanks to OS X’s hierarchy. (User folders have priority over the system folders.) We’ll make all our changes to this widget; if anything goes wrong, you can just trash it and start over with a clean copy from the system.

Control-click on your copy of the People widget and choose Show Package Contents from the pop-up menu. A new window will open, and one of the files you’ll see is named WhitePages.js. Drag and drop this file onto TextEdit (or open it with your favorite text editor). Hit Command-F to bring up the Find box, and type var mapURL as the search term. The cursor should jump to this section of the file (it’s line 877 if your text editor supports line numbering):

var mapURL = "http://www.daplus.us/showmap.aspx?";

// try to delete suite / apt # info at end of address....

Delete both of those lines, and then everything down to and including this line (line 902):

pbAlert("map url "+mapURL);

Once you’ve deleted this text, it’s time to insert the replacement code that uses Google Maps. Make sure your cursor is immediately above this line in your text file:

addressSpansContainer.setAttribute("maplink", mapURL );

Now copy and paste the following text and insert it in your file:

	var mapURL = "http://maps.google.com/maps?q=";


if (singleResult.address.length > 0)
{
mapURL += "";
var tmpAddr = singleResult.address.replace(/(s*#.*$)/, "");
mapURL += tmpAddr.replace(/s+/g, "+");
}
mapURL += "+";
mapURL += singleResult.city.replace(/s+/g, "+");
mapURL += "+";
mapURL += singleResult.state.replace(/s+/g, "+");
if (singleResult.zip.length > 0)
{
mapURL += "+";
mapURL += singleResult.zip.replace(/s+/g, "+");
}

mapURL += "+";
mapURL += "(";
mapURL += singleResult.firstname.replace(/s+/g, "+");
mapURL += "+";
mapURL += singleResult.lastname.replace(/s+/g, "+");
mapURL += ")";

When you’re done, save your changes and quit your text editor. Invoke Dashboard, then close the People widget (if it was open). Open the People widget, and enter someone’s first name, last name, city, and state. When the results appear, click the address, and you should be rewarded with a Google Map of the person’s location.

If something isn’t working right, return to the Finder and dispose of your copy of the People widget (the one in your users folder /Library/Widgets folder). Make a new copy from the top-level Library/Widgets folder and try again.

Shop Tech Products at Amazon