10.4: Use Google Maps with the Address Book widget

May 29, '05 10:26:00AM

Contributed by: unixrocks

Tiger only hintThis is a follow-up to an idea that I posted in the comments to the hint to replace the Phone Book widgets mapping service. I worked it all out, so here's how you do it. The Address Book widget uses compiled code to set the URL, so I replaced the URL string in the binary with a URL string pointing to the Google maps server.

The URL string has a lot of +++ signs at the end of it, because the replacement string has to match the original length exactly. Google ignores these, so it may look a bit weird for short URLs, but it works. Copy and paste this script, and create a script using your editor of choice. I call the script change_abwidget.ksh. AFter it's created, then issue the command:

$ chmod 755 change_abwidget.ksh
You need to be root to run this so:
$ sudo ./change_abwidget.ksh
The first time you run it, the script will back up the origional Address Book widget code (inside the package), make one copy for the Mapquest server, another for the Google server, and change the Address Book widget to use the Google server. On subsequent runs, it will figure out which version you are running, and then change it over to the other version -- that is, toggle between Google and Mapquest.

[robg adds: This is a really useful modification, as Google's maps are so much easier to read than those from Mapquest. Please note that I modified the script as originally submitted -- in the comment thread linked above, user 'pediddle' pointed out that the query had trouble with the country code in the URL, and provided an alternate. When I tested the original script, it wouldn't work at all. I then hex-encoded the replacement, and it worked perfectly. So that's the one that's in the script, but I left the original hex string in place as a comment, in case you want to try that one (for non-US addresses, it may work better).

The other thing I did was made a copy of the Address Book widget in my user's Widgets folder, and then changed the second line of the script (the cd line) to point to my local copy -- this way, my original is unmodified, but Dashboard will use the local copy instead of the stock copy, since the modified version is in my user's folder. This also means I don't need to use sudo to run the script...]

Comments (20)


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