Refactor GeoRSS Layer to support 'real' GeoRSS :) (geo:lat, geo:lon).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@783 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-06-27 04:04:41 +00:00
parent d7bb634cce
commit 067bbb5d75
2 changed files with 18 additions and 11 deletions

View File

@@ -30,8 +30,7 @@ OpenLayers.Layer.GeoRSS.prototype =
OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name]);
this.location = location;
this.features = new Array();
new Ajax.Request(location,
{ method: 'get', onComplete:this.parseData.bind(this) } );
OpenLayers.loadURL(location, null, this, this.parseData);
},
/**
@@ -59,18 +58,25 @@ OpenLayers.Layer.GeoRSS.prototype =
if (!doc || ajaxRequest.fileType!="XML") {
doc = OpenLayers.parseXMLString(ajaxRequest.responseText);
}
var pointlist = doc.getElementsByTagName('point');
for (var i = 0; i < pointlist.length; i++) {
var itemlist = doc.getElementsByTagName('item');
for (var i = 0; i < itemlist.length; i++) {
var data = {};
var location = pointlist[i].firstChild.nodeValue.split(" ");
if (location.length != 2)
var point = OpenLayers.Util.getNodes(itemlist[i], 'georss:point');
var lat = OpenLayers.Util.getNodes(itemlist[i], 'geo:lat');
var lon = OpenLayers.Util.getNodes(itemlist[i], 'geo:long');
if (point.length > 0) {
var location = point[0].firstChild.nodeValue.split(" ");
} else if (lat.length > 0 && lon.length > 0) {
var location = [parseFloat(lat[0].firstChild.nodeValue), parseFloat(lon[0].firstChild.nodeValue)];
} else {
continue;
}
location = new OpenLayers.LonLat(parseFloat(location[1]), parseFloat(location[0]));
var title = OpenLayers.Util.getNodes(pointlist[i].parentNode, "title")[0].firstChild.nodeValue;
var description = OpenLayers.Util.getNodes(pointlist[i].parentNode, "description")[0].firstChild.nodeValue;
try { var link = OpenLayers.Util.getNodes(pointlist[i].parentNode, "link")[0].firstChild.nodeValue; } catch (e) { }
var title = OpenLayers.Util.getNodes(itemlist[i], "title")[0].firstChild.nodeValue;
var description = OpenLayers.Util.getNodes(itemlist[i], "description")[0].firstChild.nodeValue;
try { var link = OpenLayers.Util.getNodes(itemlist[i], "link")[0].firstChild.nodeValue; } catch (e) { }
data.icon = OpenLayers.Marker.defaultIcon();
data.popupSize = new OpenLayers.Size(250, 200);
data.popupSize = new OpenLayers.Size(250, 100);
if ((title != null) && (description != null)) {
contentHTML = "<br />";
contentHTML += "<div style='margin: -0.5em 0.5em 0.5em 0.5em'>"