diff --git a/examples/georss.html b/examples/georss.html index 496046d239..483fc16512 100644 --- a/examples/georss.html +++ b/examples/georss.html @@ -14,13 +14,14 @@ var map, layer; function init(){ + OpenLayers.ProxyHost = '/proxy/'; map = new OpenLayers.Map('map', {maxResolution:'auto'}); layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} ); map.addLayer(layer); - var newl = new OpenLayers.Layer.GeoRSS( "text", "./georss.xml" ); + var newl = new OpenLayers.Layer.GeoRSS( "text", "http://earthquake.usgs.gov/eqcenter/recenteqsww/catalogs/eqs7day-M2.5.xml" ); map.addLayer(newl); map.setCenter(new OpenLayers.LonLat(0, 0), 0); diff --git a/lib/OpenLayers/Layer/GeoRSS.js b/lib/OpenLayers/Layer/GeoRSS.js index 8a93e60e62..09a90caf68 100644 --- a/lib/OpenLayers/Layer/GeoRSS.js +++ b/lib/OpenLayers/Layer/GeoRSS.js @@ -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 = "
"; contentHTML += "
"