The main problem with GeoRSS is that there are several GeoRSS standards for specifying locations. This makes it hard both for those creating the GeoRSS feeds and those doing something with those feeds. See for example Aaron's blog and the GeoRSS response.
GeoRSS GML - http://georss.org/gml.html
<georss:where>
<gml:Point>
<gml:pos>45.256 -71.92</gml:pos>
</gml:Point>
</georss:where>W3C "formal" - http://www.w3.org/2003/01/geo/
<geo:Point>
<geo:lat>55.701</geo:lat>
<geo:long>12.552</geo:long>
</geo:Point>So far it seems to me that the latter one - "W3C casual" is the most widely used.
I wanted to be able to map a georss feed onto a map myself (and work on my javascript skills). I could have used some of the built-in GeoRSS support, but I wanted more control of both display of the the markers as well as being able to display them outside the map.
Here's the sample javascript I came up with to parse any of these georss feeds:
[See a live sample]
var items = xmlDoc.documentElement.getElementsByTagName("item");
for( var i = 0; i < items.length; i++ )
{
var itemtags = items.item(i).getElementsByTagName("*");
for ( var j = 0; j < itemtags.length; j++ )
{
var tag = itemtags[j].nodeName;
if (tag == 'geo:lat') {
var lat = itemtags[j].firstChild.data;
} else if (tag == 'geo:long') {
var lon = itemtags[j].firstChild.data;
} else if (tag == 'georss:point') {
var ptArr=itemtags[j].firstChild.data.split(" ");
var lat = ptArr[0];
var lon = ptArr[1];
} else if (tag == 'gml:pos') {
var ptArr=itemtags[j].firstChild.data.split(" ");
var lat = ptArr[0];
var lon = ptArr[1];
}
}
} [See a live sample]
It seems simple, maybe I'm missing something?
2 comments:
Great script example. GeoRSS is meant to be simple, easy to use, and understandable. It's interesting that , due to past experience, we expect standards to be complex and difficult.
W3C casual is currently 'common', but I would say GeoRSS Simple is probably becoming the most widely used and the suggested future use.
Also, your example of W3C 'formal' is incorrect, the parent tags should be geo:Point.
Thanks Andrew. I cleaned up the 'formal' syntax to use "geo:Point".
Post a Comment