I keep the latitude and longitude for each of my posts. My blog’s RSS feed is generated from the list of posts. Until now it was a plain simple RSS feed but why not enhance the RSS feed with the post’s coordinates? They are there anyway and GeoRSS is widely adopted these days.
What is GeoRSS?
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 diverse ways: pinpointing on a map, finding other posts close to this one, etc.
What we need
Generating the feed is out of scope, but we’ll add location awareness to our existing feed. See Larry Myers’ How To Generate RSS Feeds with Rails article to get started.
We’ll need to add a single XML element to each item of the feed with the latitude and longitude coordinates for each post.
In Ruby on Rails the syntax looks a little strange as we need a way to add the ‘georss:point’ XML element and Ruby doesn’t like the colon in there (see Ruby symbols).
Next, we add the GeoRSS namespace to the top of the feed to tell the feed parsers what we mean.
My location aware RSS feed
The full view template should now resemble the following:
That’s it. Not too exciting at first but enter your RSS feed URL in Google Maps and see how easy it is to mark each post on a map!