Geo this! Geolocate Wordpress posts with Greasemonkey and Yahoo Placemaker

Geolocating content on the web is a great idea. By embedding latitude and longitude and real place names in your document you allow data mining for location or easy display on a map.

The problem up to now was that it is quite a job to find out the correct geo information from a text or a document and it is quite a pain to enter the information by hand.

Yahoo Placemaker is a web service that helps you with that – you give it some text or a document URL and it returns you all the things it found in there that resemble a geographical location back. The issue with doing that on a live site is that you slow down your site immensely as you need to look up every time.

The more logical place to do the lookup with Placemaker is when you edit your document. I thought this would be cool to have for this WordPress install here and wrote a small GreaseMonkey script that injects a new “Geo this!” button in the main WP form:

Geo this - button by  you.

When I hit the button the script does an Ajax request using the Placemaker open YQL table to get the information for the currently edited text.

Once it found the information it adds it at the end of the document as a GEO microformat. Each found entry starts with a comment that tells you what Placemaker matched and considered a geographical location. As it is not infallible this makes it easy for you to delete wrong entries.

Geo this - added microformats by  you.

Try it out yourself:

This is pretty much rough and ready and I’d be happy for feedback how to improve it.

Tags: , , , , , ,

3 Responses to “Geo this! Geolocate Wordpress posts with Greasemonkey and Yahoo Placemaker”

  1. Frode Danielsen Says:

    After recently hacking on a WordPress blog which wanted to publish a Google Map with some of the posts, this looks really cool. The solution on the blog I worked on for now was a simple custom field with the address for a Google Map (defined through My Maps). But this would be really nice as a real plugin for WordPress, maybe with a TinyMCE editor button for “geo lookup”.

    Also, storing lat,lng in custom fields would also be a nice alternative to a full markup of the geo data in the post itself.

  2. Ara Pehlivanian Says:

    Very cool, but why not a WordPress plugin? That way you don’t need to have GreaseMonkey running in order to have the script. You know like if you blog on a friend’s machine or something. Just sayin’:-)

    Otherwise, awesome idea.

  3. Ara Pehlivanian Says:

    Frode: Storing the values in custom fields is fine but you want the data to appear in the post as a microformat so that it can be consumed by microformat parsers reading the page. Either way, whether stored in fields or directly in the post, the data will have to make its way into the final render of the page anyway, so why not just store it in the post to begin with?

Leave a Reply

Wait till I come! is the blog of Christian Heilmann , a developer evangelist living and working in London, England. Download vcard.

Feed me, Seymour: Entries (RSS) and Comments (RSS).