I keep the latitude and longitude for each of these blog post (as you can see in the right hand column). My blog’s RSS feed is generated from my posts table. Until now it was a plain simple RSS feed but why not combine the 2 and enhance my RSS feed with the coordinates? They are there anyway and GeoRSS is widely adopted these days.
GeoRSS is a way to encode location information in RSS feeds. This can be as simple as adding one small XML element to your existing feed. GeoRSS feeds are designed to be consumed by geographic software such as map generators and by doing so your feed can be used in new and different ways: pinpointing on a may, finding other posts close to this one, etc.
Generating the actual RSS feed is not in the scope of this article, we'll only add location awareness to our existing feed. Please head over to Larry Myers’ How To Generate RSS Feeds with Rails article if you don’t generate your feed yet.
We’ll need to add one small XML element to each item in our feed with the latitude and longitude for the post:
In Ruby on Rails this looks like the following (where latitude and longitude are 2 fields in our posts table). The syntax looks a little strange as we need a way to add the ‘georss:point’ element and Ruby doesn’t like the colon in there (it indicates a symbol).
Great, now we only need to add the GeoRSS namespace at the top of our feed to tell the feed parsers what we mean.
The full view template should now resembles something like this:
That’s it. Not too exciting at first but try your RSS feed URL in Google Maps and see how easy it is to pinpoint each location on a map.
This post is open source. Did you spot a mistake? Ideas for improvements? Contribute to this post via Github. Thank you!