Adding a Geolocation Button to WordPress with Greasemonkey, YQL, and Placemaker

Adding geographical information to a text on the Web is a terribly useful thing. For one, you can then display the information on a map and give it visual context. Furthermore, web users are becoming more mobile with the help of laptops, free wireless, and smart phones. Being able to identify relevant geographical location for a document would allow search engines and other websites to match users in a given area or point searchers to a geographically relevant document. Plain text search doesn't quite cut it, as location names can also be names of people or events. Just do a search for "one night in Paris" if you don't believe me.

Geolocating content can be done using several open services - including Yahoo! Placemaker. (If you want a library that uses several services check out Simon Willison's Geocoders.) The issue is that adding geodata to existing content can be quite tedious until you find a nice and easy way to batch-process content.

We need easy-to-use geo lookups when we edit texts-- in other words, before publication. There are plugins for CMS and blogging systems that usually work by showing you a map and setting the location manually. This is too much work for me.

Geo This (also available on GitHub) is a Greasemonkey script for Firefox that ties in with WordPress installations and shows you a button labelled "geo this" under your editor:

Geo this - button by  you.

Pressing this button will take the content of the field, send it to Placemaker and return you all the content it finds as GEO microformats. Each of the entries starts with an HTML comment telling you what Placemaker found so you can delete false positives.

Geo this - added microformats by  you.

I will keep working on this to make it a generic JavaScript that could be added to any form, if there is interest. Contact me on GitHub, add a comment here, or follow the discussion on my personal blog.

Chris Heilmann
Yahoo Developer Network