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

10.4: Replace the phone book widget's mapping service System 10.4
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!]
    •    
  • Currently 2.33 / 5
  You rated: 4 / 5 (6 votes cast)
 
[52,862 views]  

10.4: Replace the phone book widget's mapping service | 35 comments | Create New Account
Click here to return to the '10.4: Replace the phone book widget's mapping service' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Replace the phone book widget's mapping service
Authored by: boshea on Apr 29, '05 11:27:09PM

Very nice! I had to add a comma after the address & city to make it work :

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



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: Stoopa on Apr 30, '05 12:14:28AM

This is great! But how to do it with the Address Book widget? There's nothing in the .js file that seems to point to Mapquest...



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: Swift on Apr 30, '05 08:43:16AM

Why is this not working for me? I've changed the text block, but it still goes back o mapquest. (shudder). Is TextEdit just too wimpy?

---
------------------------
Screenplays for Royalty
since 1749



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: Schmidlapper on Apr 30, '05 12:23:46PM

TextEdit worked well for me as an editer for this.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: tifighter on May 03, '05 10:00:37PM

You must make sure you are replacing the actual string... not the example search just above the string.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: sauron1440 on Apr 30, '05 04:49:46PM

Some addresses fail without further formatting - for example, an address with a suite number (# 240, etc) will screw up google maps, as it seems to ignore everything after the #. I need to brush up on my l33t JS skills, but if I figure anything out, I'll post it here.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: drewk on Apr 30, '05 05:04:07PM

I posted the fix in the thread. Try it.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: RonC on Dec 19, '05 10:23:04AM

I copied the code for changing to Google as the mapping tool in the Address/Phone directory on my iBook. Each time I invoke the mapping scheme, I still get Mapquest.
Let me state that I am a 'newbie' when it comes to Mac's, and I'm probably doing something out of order or in error.
Can someone redo the steps it takes to complete the task to change to a Google mapping tool??

RonC
Austin, TX



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: g4macuser on Apr 30, '05 01:55:39AM

any way to get it to look in canada?



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: dimmak on May 01, '05 02:05:33AM

Not until Google.com creates the ability to go outside the US.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: argh128 on May 01, '05 10:35:43AM

Actually, it does work in Canada.

http://maps.google.com/maps?q=Calgary,+AB&spn=1.255859,1.278249&hl=en

---

A completely SANE Canadian.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: dylan1489 on Aug 01, '05 07:33:25AM

i would also like it to work in canada. doesn't look like it would be too hard for someone who knows a little about this stuff.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: milesgehm on Apr 30, '05 11:45:34AM

This works great. I couldn't figure out how to do the same thing ADDRESS BOOK.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: merkhet on Apr 30, '05 01:22:01PM

I believe the reason is because the Address Book widget is directly linked to the map process for the Address Book application.

So the real question is: how do you change the Address Book application to use Google Maps instead of Mapquest.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service - Like this...
Authored by: unixrocks on Apr 30, '05 09:26:52PM

I messed with this and got it working but it is ugly.

Addressbook widget uses compiled code - so you need to fire up a hexeditor to get this to work. I used HexEdit which I think is just a great hex editor.

/Library/Widgets/Address Book.wdgt/AddressBook.widgetplugin/Contents/MacOS/AddressBook

is the binary in question.

Back it up - and I personally copied it to the desktop as root and edited it there and then copied it back again - just easier then messing with permissions in the program directory. Use overwrite mode in HexEdit - its easier.


Find the following string:

http://www.mapquest.com/maps/map.adp?country=%@&address=%@&city=%@&state=%@&zip=%@

and replace it with:

http://maps.google.com/maps?q=%@+%@+%@+%@+%@++++++++++++++++++++++++++++++++++++++

No room for error here - your replacement string has to be exactly the same length as your origional string or it wont work - the program will just crash or some other nonsense.

Google ignores the extra +++++ signs so it works put it looks a little odd with a large browser window or a short address.

Save the file in hexedit, copy it back to the origional directory and you have to remove addressbook from dashboard and then bring it up again (command-R wont work with this one)

If someone has a neater and cooler way of doing this I would love to learn (keep thinking I could use xxd here but so far I just keep clobbering the file when I try. =-)





[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service - Like this...
Authored by: pediddle on May 01, '05 04:33:02PM

Google doesn't always understand the country code, and it seems to need commas separating address, city, and state, so here's string that might work better for some addresses. Note that Google ignores the "country=..." parameter altogether, so if you want directions outside of the US, this probably won't work...

<tt>http://maps.google.com/maps?country=%@&q=%@,+%@,+%@+%@&bogus=+++++++++++++++++++++</tt>

This also hides the extra spaces in a bogus field and should be exactly the length required.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service - Like this...
Authored by: milesgehm on May 01, '05 05:05:30PM

This worked. Thanks.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: Swift on Apr 30, '05 01:45:01PM

Erm... I actually had changed my Phone Book to google. But I missed the little step to "Refresh" the Widget. (Cool animation, yeah?) D'oh!

---
------------------------
Screenplays for Royalty
since 1749



[ Reply to This | # ]
Didn't work for me....
Authored by: rahenkamp on Apr 30, '05 02:21:39PM

I have the code below and it does not work for me either. Keeps going back to mapquest and there is no reference to mapquest anywhere in the rest of the file.

d

// example query

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 );



[ Reply to This | # ]
Didn't work for me....
Authored by: ateles on Apr 30, '05 09:12:43PM

Make sure you have administrative priveleges to change the file...It is in /Library, and therefore outside of your home folder...

If you are familiar with the terminal type:

cd /Library/Widgets
cd cd Phone\ Book.wdgt/
sudo vi Phonebook.js

assuming you know how to use the text editor vi..

J.

---
Eco-programmer by heart



[ Reply to This | # ]
Didn't work for me....
Authored by: alajuela on May 01, '05 01:10:39PM

Yes, I have admin privileges, and actually, the file contains the correct code. No matter what, and I have now tried all three versions of the hint, it keeps going back to that butt-ugly MapQuest.



[ Reply to This | # ]
Didn't work...Address book, not phone book
Authored by: zedwards on May 02, '05 01:26:07PM

I did this too...The app you want to fix is Address book, not Phone book.



[ Reply to This | # ]
Didn't work...Address book, not phone book
Authored by: zedwards on May 02, '05 01:30:25PM

Now I'm really confused.

This IS for the phonebook app, but people are asking about address book. Anyways...disregard.



[ Reply to This | # ]
Didn't work for me....
Authored by: Swanvestas on May 10, '05 11:31:33PM

I'm having the same problem.

Following all the threads to date...I have adminstrative privileges. Swapped the "correct" code (not the same code above it). Tried both versions from the original hint. Also tried the version adding the comma before the + sign. Actually downloaded someone else's posted PhoneBook.js file (with the Google Maps code already built in.) Have confirmed that it's the "PhoneBook.wdgt" file and not the "Address.wdgt" file where the PhoneBook.js file is found. (AddressBook.wdgt does not have any referral code to Mapquest. (Refreshed the widget, even rebooted, cleaned caches, etc.)

After all this I still get the MapQuest site!

Anybody else still stuck as well?



[ Reply to This | # ]
Didn't work for me....
Authored by: jconstant on May 21, '05 05:09:42PM

Duh, I finally figured it out. The problem was me being an idiot.

I changed the phonebook.js file properly - but I was using my Address Book widget to try to look up an address! The widget that this change will appear in is the 'Yellowpages' looking widget, not the Address Book widget. I wish there was a similar way to change which map service the Address Book widget uses.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: bvdecicco on Apr 30, '05 03:08:28PM

I got it to work without a problem too. I used the shorter of the 2 code block examples. I poked around the .js file in the addressbook package but nothing jumped out as easily as it did in the phonebook. Oh well.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: El Payo on May 04, '05 10:09:59PM

The Address Book widget hooks directly into the data that Address Book app stores, which includes URL map locations of the adresses stored. These addresses parsed and looked up on Apple's servers using MapQuest and then the URL is returned to Address Book to store in the contact file.

So getting Address Book widget to use Google would mean getting Apple to rewrite it's lookup system to use Google.

See my post futher down for more info.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: drewk on Apr 30, '05 04:03:52PM
This is a wonderful hint!

However, there is still a bug in Apple's Yellow Pages widget carried into this hint.
Apple uses DA+ for the Yellow Page data. DA+ listings may or may not include the Suite Number like this:

Michele Coulon Dessertiere
7556 Fay Ave # D
La Jolla CA 92037

If the suite number is included, this gets added to the URL sent to Google (or Mapquest.) With the extra suite or unit in the URL, neither this Google Map hint not Mapquest default from Apple will display a map.

Here is the fix. Add a regular expression that removes the '#' and the space before it and everything after it. Instead of the code in step 6 contained in the Google Map hint, use this code so that both an address with or without a suite number will display correctly in Google Map:

var mapURL = "http://maps.google.com/maps?q=";
//The following RegEx removes the unit or suite number 
//that otherwise breaks Google Maps
mapURL += URLEncode( singleResult.address.replace(/(\s*#.*$)/, "") );
mapURL += ",+"; 
mapURL += URLEncode( singleResult.zip );
// add "&t=k" if you want sat view
mapURL += "&hl=en";

Thanks again for the great hint!

drewk

[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: Lectrick on Apr 30, '05 04:41:40PM
I got this to work with two caveats: 1) Add a comma immediately before the + sign in the two lines that insert a plus after Address and City.

			mapURL += URLEncode( singleResult.address );
			mapURL += ",+";
			mapURL += URLEncode( singleResult.city );
			mapURL += ",+";
2) Make sure you command-R to reload the widget (nice animation!!) Then it worked for me.

---
In /dev/null, no one can hear you scream

[ Reply to This | # ]

10.4: Replace the phone book widget's mapping service
Authored by: oxjox on May 01, '05 02:27:43PM

Works great!!

Can you do the same thing with Address Book?!!



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: El Payo on May 04, '05 09:45:28PM
Actually, no. Apple has offloaded the lookup in the Address Book app to a server they host:

http://si.info.apple.com/services/addressbook.xml

Take a look at the source of that page and you'll see they do a lot of parsing of addresses for multiple countries and other code fu. The link to that site is contained in the file found inside Address Book at:
~/Applications/Address\ Book.app/Contents/Resources/English.lproj/ABTextActions.strings
I tried simply replacing the URL there with what I thought would be a Google maps query, but I'm not sure how to properly format the URL so it will use whatever parameters/variables that Apple assigns to the address.

Anyone else want to poke around and try, or should we report use of MapQuest as a bug and get them to rebuild their page to use Google Maps?

[ Reply to This | # ]
Where to keep the modified widget
Authored by: duien on May 03, '05 07:54:54PM

Like a lot of things in OS X, the copy of a widget in ~/Library will override the copy in /Library. So what I did was put the modified widget in my user library and leave the original where it started out. Only one copy shows up on the add widget bar on dashboard and its the correct one. And that way if I decide to go back to the default, I just have to delete the one in my user library and don't have to go looking for where I stashed the other one.



[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: EvanO on May 27, '05 06:06:37PM
As a huge fan of Google Maps satellite images I thought I'd edit PhoneBook.js to map the address via a satellite image by default.
It's easy.

Replace:
mapURL += "&hl=en";
with
mapURL += "&t=k&hl=en";
Hope it works for you.

[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: capacity on Jan 16, '06 04:24:42PM
To make clicking on the resulting address actually search Google Local for the business name near the resulting address, rather than just go to a map of the address, use this chunk of code:

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

mapURL += singleResult.name.replace(/\s+/g, "+");
if (singleResult.address.length > 0)
    {
	mapURL += "&near=";
	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, "+");
    }
Note: After every
.replace(
there is a forward slash, back slash, the letter s, plus sign, forward slash, the letter g, comma, double quote, plus sign, double quote, end parentheses, and semicolon.

[ Reply to This | # ]
10.4: Replace the phone book widget's mapping service
Authored by: mortman on Jan 17, '06 09:15:46AM

I need help to implement this hint. I've tried a zillion timesand can't get it to work . I have beensuccessful in making the changes to use Google Maps for the Address Book and People widgets bur failing miserably for the phonebook.

Can anyone please help.

Thank you.



[ Reply to This | # ]