[OpenLayers-Users] Syntax for the GeoRSS call?
Alexandre Leroux
alexandre.leroux at ec.gc.ca
Tue Feb 6 14:44:08 EST 2007
Hi list,
OpenLayers's GeoRSS example ask you to feed the url through a textbox. I
have failed to find the right syntax to send it directly.
My last attempt was:
OpenLayers.Layer.GeoRSS("Slashgeo", "http://slashgeo.org/index.rss");
map.addLayer([georss_layer]);
but it doesn't work. What's wrong? (I have tried multiple permutations,
including removing the [] on georss_layer)
I tried with the live example on
http://openlayers.org/dev/examples/georss.html and of course it works.
However, for some reason, the georss feed doesn't show up when testing
the example locally using the georss.html example bundled with the files.
I copied my full code below just in case. Thanks!
Alex
--
Alexandre Leroux, M.Sc., Ing.
Environnement Canada / Environment Canada
Centre météorologique canadien / Canadian Meteorological Centre
Division de la réponse aux urgences environnementales /
Environmental Emergency Response Division
alexandre.leroux at ec.gc.ca
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 1000px;
height: 700px;
border: 1px solid black;
}
</style>
<script
src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, layer, georss_layer;
// OpenLayers.ProxyHost = "/proxy/?url=";
function init(){
map = new OpenLayers.Map('map', {maxResolution:'auto'});
layer = new OpenLayers.Layer.Google( "Google Satellite" ,
{type: G_NORMAL_MAP, 'maxZoomLevel':18} );
map.addLayers([layer]);
// layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
// "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
// map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0, 0), 2);
georss_layer = new OpenLayers.Layer.GeoRSS("Slashgeo",
"http://slashgeo.org/index.rss");
map.addLayer([georss_layer]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
}
function addUrl() {
var value = $('url').value;
var parts = value.split("/");
var newl = new OpenLayers.Layer.GeoRSS(
parts[parts.length-1], value);
map.addLayer(newl);
$("url").value = "";
}
// -->
</script>
</head>
<body onload="init()">
<h1>GeoRSS in OpenLayers</h1>
<p style="font-size:.9em;">This demo uses the OpenLayers GeoRSS
parser, which supports GeoRSS Simple and W3C GeoRSS. Only points are
currently supported. <a
href="http://trac.openlayers.org/wiki/HowToDownload">Get the code!</a></p>
<form onsubmit="return false;">
GeoRSS URL: <input type="text" id="url" size="50" /><input
type="submit" onclick="addUrl(); return false;" value="Load Feed"
onsubmit="addUrl(); return false;" />
</form>
<div id="map"></div>
http://slashgeo.org/index.rss
</body>
</html>
More information about the Users
mailing list