2005-09-11

GeoURL bookmarklet

Upon stumbling upon GeoURL today, and before further stumbling on the GeoURL firefox extension, I made a quick scriptlet hack to see a GeoURL marked page in Google Maps, meaning to develop it a bit further into a GreaseMonkey script, if I eventually get another inspiration going with the Google Maps API. It's at least somewhat neat, and I love the expressivity of a tiny chunk of javascript code:
var meta = document.getElementsByTagName('meta'), data = {}, i, ll, at;
for( i=0; i<meta.length; i++ )
if( meta[i].name && meta[i].content )
data[meta[i].name.toLowerCase()] = meta[i].content;
if( (ll = data['geo.position'] || data.icbm) &&
(ll = ll.split( / *[:;,] */ )).length == 2 )
{
at = data['geo.placename']||data['geo.region']||data['dc.title'];
ll = ll.join(',') + (at ? encodeURIComponent(' ('+at+')') : '');
location = 'http://maps.google.com/maps?q='+ ll +'&t=h&hl=en';
}

blog comments powered by Disqus