Sunday, January 28, 2007

Google Mapit bookmarklet

Here's a simple bookmarklet that I cobbled together because I got tired of copying and pasting addresses from the browser into Google maps, and then having to do it twice because the multi-line copy/paste didn't work. You should be able to drag this right onto your toolbar:

Mapit

Then you just highlight an address and click it, or setup a hotkey for it. I haven't tested it across all browsers yet, but it's working fine in Camino, Firefox, and Safari on my mac.

Here's a prettier version so you can see what it does:

javascript:var url = 'http://maps.google.com/maps?q=';
if (window.getSelection) {
var sel = window.getSelection() + '';
url += sel.replace(/\n/g,%22, %22);
} else if(document.getSelection) {
url += document.getSelection();
} else if (document.selection) {
url += document.selection.createRange().text;
}
void(window.open(url));