Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Use Google Maps with the Address Book widget System 10.4
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...]
    •    
  • Currently 3.00 / 5
  You rated: 3 / 5 (4 votes cast)
 
[15,449 views]  

10.4: Use Google Maps with the Address Book widget | 20 comments | Create New Account
Click here to return to the '10.4: Use Google Maps with the Address Book widget' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Use Google Maps with the Address Book widget
Authored by: lonepalm on May 29, '05 01:21:19PM

Hey Robg,

Can you post your script so the less inclined like me can more easily implement this ?

Thx, Mike



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: reh on May 29, '05 01:32:05PM

He did. It's the script link in the hint.



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: z5591 on May 29, '05 02:51:14PM

Since I'm an idiot, I have absolutely no idea how to do this. Could a smart person give me step-by-step instructions?



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: reh on May 29, '05 03:02:28PM
  1. Download the script by option clicking on this link
  2. Open the Terminal and type "chmod 755 " (minus the quotes and don't forget the space on the end... DON'T hit enter yet)
  3. Now drag the recently downloaded script into the Terminal and hit enter
  4. Type "sudo " into the terminal (with the space and DON'T hit enter yet)
  5. Drag the script into the Terminal again and hit enter; type your password when prompted
  6. Remove the address book widget from your dashboard and add it again.
  7. Search for a contact with an address and click on the address. You should now get sent to Google Maps. Don't forget to hit Google's satellite link to see images of the area.


[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: apikoros on Jun 01, '05 07:57:50AM

reh, I too am a newbie. Following your instructions, at your step 5 I see this in Terminal:

"We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility."

I was not expecting a lecture. It looked suspect, so I canceled the procedure right there. Was that message to be expected?

If so, I'll try it again, but have another question regarding the last step: just how does one remove the address book widget from dashboard and add it again? Thanks in advance--



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: unixrocks on May 29, '05 03:07:36PM

Sure - do this.

copy the script thats linked in the origional post (open the link in a new window - select all text in the window (command-A) then copy to the buffer (command-C))

create a new file using textedit under your home directory called change_abwidget.ksh - paste the contents of the buffer into the file (command-v) - or to be more accurate create a new file in simple text, copy the contents of the buffer, then save it to your home directory to a file called change_abwidget.ksh

open a terminal window (it will drop you into your home directory where the script is) and enter the following <actual dialog copied and pasted below from terminal but of course your prompt will differ>


[Chris-Computer:~] Chris% chmod 755 change_abwidget.ksh
[Chris-Computer:~] Chris% sudo ./change_abwidget.ksh

AddressBook is currently set for MapQuest server - changing it to use Google server...

Dont forget in order for the change to take affect you must re-launch the AddressBook Widget in Dahsboard.
Just refreshing the widget via Command-R wont force the changes to take affect.
You can also have two copies of the AddressBook running - one with MapQuest the other with Google.




[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: ershler on May 29, '05 11:35:58PM

I've tried the following

Macintosh-2:/Library/Widgets ershler$ sudo /Users/ershler/Desktop/GoogleMaps.sh

AddressBook is currently set for MapQuest server - changing it to use Google server...

Dont forget in order for the change to take affect you must re-launch the AddressBook Widget in Dahsboard.
Just refreshing the widget via Command-R wont force the changes to take affect.
You can also have two copies of the AddressBook running - one with MapQuest the other with Google.
Macintosh-2:/Library/Widgets ershler$

Then I removed the Phone Book Widget from the screen and then reinstalled it. But it still goes to MapQuest. I've tried picking up a fresh copy of the widget and rerunning the script. No change.



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: macavenger on May 31, '05 01:30:46PM

You are running into the same problem I had - this hint is for the Address Book widget, not the Phone book widget.

---
iMac FP 17" 800MHz OS X 10.4.x



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: matthewfritz on May 29, '05 11:36:24PM

I can't seem to get this to work... I get the following error in Terminal

fritzm% sudo /Users/fritzm/Desktop/address_widgetscript.ksh
/Users/fritzm/Desktop/address_widgetscript.ksh: line 1: {rtf1macansicpg10000cocoartf824cocoasubrtf100: command not found
/Users/fritzm/Desktop/address_widgetscript.ksh: line 2: syntax error near unexpected token `}'
/Users/fritzm/Desktop/address_widgetscript.ksh: line 2: `{\fonttbl\f0\fnil\fcharset77 Verdana;}'



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: robg on May 30, '05 09:35:13AM

Looks like you saved the script as RTF -- make sure TextEdit is set to save in plain text mode.

-rob.



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: matthewfritz on May 31, '05 11:16:19PM

Thanks. Now that I set it to txt, I'm getting the "Changing the Address book..." message and close the addressbook widget then reinstall it but it still queries MapQuest...



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: MarcodD on Jul 30, '05 12:14:04PM

Now it's my turn to to an idiot. What is the home directory?



[ Reply to This | # ]
10.4: Idiot level instructions on how to change the phonebook widget to check google maps?
Authored by: pooper on May 31, '05 12:02:42AM

thanks for the advice, everyone.
can you give me like idiot level instructions on how to change the phonebook widget to check google maps, too?
sorry if this is totally OT, but I'm a total newb and I'm trying to learn.



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: sirion on May 30, '05 12:05:17AM

I got this to work, but it can't handle addresses with apartment numbers in them.

For:
1010 19th Street #8
Santa Monica CA 90403

The URL it feeds google is:
http://maps.google.com/maps?country=us&q=1010+19th+Street+#8,+Santa+Monica,+CA+90403&bogus=+++++++++++++++++++++

Which google interprets as:
http://maps.google.com/maps?q=1010+19th+Street

Any ideas as to how to fix this?



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: sirion on May 30, '05 01:41:11AM

I'm noticing a fix proposed in the Phonebook widget thread, but it would have to be incorporated into the code of the script.

The useful line of code is
mapURL += URLEncode( singleResult.address.replace(/(\s*#.*$)/, "") );

which kills the suite/apt number



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: lucite on Jun 05, '05 01:16:03PM
Unfortunately, I see no way to make that work here (at least directly) because what gets passed is not the actual URL query: http://maps.google.com/maps?country=%@&q=%@,+%@,+%@+%@&bogus=+++++++++++++++++++++

[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: rdallen2 on May 30, '05 02:24:40PM

I'm running into a syntax error when I place this into Script Editor. It highlights the first two characters of the script (#!). Any ideas what the problem could be?



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: daveschroeder on May 30, '05 03:55:06PM

This is not an AppleScript, and has nothing to do with Script Editor.

It is a UNIX shell script, which needs to be run from a UNIX command prompt (i.e., Terminal).



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: simplyodd on May 30, '05 04:30:36PM

Script Editor is for Applescripts and this is not an Applescript but a unix shell script. Even if you don't know about shell scripts, (I certainly don't) just follow REH and UNIXROCKS's instructions above, exactly, and all should work. I did have to fight Tiger a little to get rid of the txt extension. Do a GetInfo on the ksh script in the Finder to make sure it truly does not have a .txt extension that's being hid. If so delete it in the GetInfo window and select the option to not hide the extension. I used the .ksh extension and used Robs tricks make & mod a widget in my user library so didn't have to use sudo and it worked great.

This is another fantastic mod. Great work guys and thanks!

tom



[ Reply to This | # ]
10.4: Use Google Maps with the Address Book widget
Authored by: lucite on Jun 05, '05 01:20:51PM

FYI, if you haven't figured it out, the problem comes from the # sign before the apt., otherwise it works fine with "no. " instead...



[ Reply to This | # ]