Geo this! Geolocate WordPress posts with Greasemonkey and Yahoo Placemaker
Monday, June 22nd, 2009Geolocating 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:
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.
Try it out yourself:
- Install Geo this!
- Check out the source on github
This is pretty much rough and ready and I’d be happy for feedback how to improve it.