Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenLayers GeoRSS parsing - All points on top of each other
    primarykey
    data
    text
    <p>I'm following an OpenLayers tutorial from OpenGeo, and am struggling with a vector layer which reads a GeoRSS encoded XML file of earthquake locations - which seems to be used a lot in these sort of tutorials. The maps produces a single point (at 0,0) which on closer examination appears to be all the points in the file stacked on top of each other so clearly something is going wrong between the translation of the point in the XML and OpenLayers.</p> <p>Here's the code:</p> <pre><code>var geographic = new OpenLayers.Projection("EPSG:4326"); var mercator = new OpenLayers.Projection("EPSG:900913"); var world = new OpenLayers.Bounds(-180, -89, 180, 89).transform( geographic, mercator ); var center = new OpenLayers.LonLat('.$centerMapLat.','.$centerMapLon.').transform( geographic, mercator ); var options = { projection: mercator, units: "m", maxExtent: world }; var map = new OpenLayers.Map("map-id", options); var osm = new OpenLayers.Layer.OSM(); map.addLayer(osm); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.setCenter(center, 2); var mapdata = new OpenLayers.Layer.Vector("Map Data", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "7day-M2.5.xml", format: new OpenLayers.Format.GeoRSS() }) }); map.addLayer(mapdata); </code></pre> <p>XML file is in the following format:</p> <pre><code>&lt;feed xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss"&gt; &lt;updated&gt;2012-01-23T09:43:22Z&lt;/updated&gt; &lt;title&gt;USGS M 2.5+ Earthquakes&lt;/title&gt; &lt;subtitle&gt;Real-time, worldwide earthquake list for the past 7 days&lt;/subtitle&gt; &lt;link rel="self" href="http://earthquake.usgs.gov/earthquakes/catalogs/7day-M2.5.xml"/&gt; &lt;link href="http://earthquake.usgs.gov/earthquakes/"/&gt; &lt;author&gt;&lt;name&gt;U.S. Geological Survey&lt;/name&gt;&lt;/author&gt; &lt;id&gt;http://earthquake.usgs.gov/&lt;/id&gt; &lt;icon&gt;/favicon.ico&lt;/icon&gt; &lt;entry&gt; &lt;id&gt;urn:earthquake-usgs-gov:ak:10395995&lt;/id&gt; &lt;title&gt;M 2.7, Alaska Peninsula&lt;/title&gt; &lt;updated&gt;2012-01-23T09:38:43Z&lt;/updated&gt; &lt;link rel="alternate" type="text/html" href="http://earthquake.usgs.gov/earthquakes/recenteqsww/Quakes/ak10395995.php"/&gt; &lt;summary type="html"&gt; &lt;![CDATA[&lt;img src="http://earthquake.usgs.gov/images/globes/60_-155.jpg" alt="57.806&amp;#176;N 156.412&amp;#176;W" align="left" hspace="20" /&gt; &lt;p&gt;Monday, January 23, 2012 09:38:43 UTC&lt;br&gt;Monday, January 23, 2012 12:38:43 AM at epicenter&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Depth&lt;/strong&gt;: 122.70 km (76.24 mi)&lt;/p&gt;]]&gt;&lt;/summary&gt;&lt;georss:point&gt;57.8058 -156.4123&lt;/georss:point&gt; &lt;georss:elev&gt;-122700&lt;/georss:elev&gt; &lt;category label="Age" term="Past hour"/&gt; &lt;/entry&gt; [:] &lt;/feed&gt; </code></pre> <p>It doesn't seem to matter what value is placed between the tags, or how many fields I cut out, the point always appears at 0,0. I can move the spot by editing the coordinates manually in firebug - this is what is rendered in the html for each point:</p> <pre><code>&lt;circle id="OpenLayers.Geometry.Point_424" cx="4.738678387182473" cy="237.58907791425827" r="6" fill="#ee9900" fill-opacity="0.4" stroke="#ee9900" stroke-opacity="1" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" pointer-events="visiblePainted" cursor="inherit"&gt; </code></pre> <p>I strongly suspect I have done something wrong, so would appreciate a sanity check</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload