Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to get features from remote GeoRSS file with Openlayers... But I am stuck. Openlayers can not read remote file. I have searched on the net but I could not find any solution... Here is the code:

map = new OpenLayers.Map('map');

var wms = new OpenLayers.Layer.WMS("Osgeo WMS",
    "http://vmap0.tiles.osgeo.org/wms/vmap0", {
    layers: "basic"
});
map.addLayer(wms);

var earthquakes = new OpenLayers.Layer.Vector("T", {
    strategies: [new OpenLayers.Strategy.Fixed()],
    protocol: new OpenLayers.Protocol.HTTP({
        url: "http://brainoff.com/test/rss.xml",
        format: new OpenLayers.Format.GeoRSS()
    }),
});
map.addLayer(earthquakes);

var select = new OpenLayers.Control.SelectFeature([earthquakes]);
map.addControl(select);
select.activate();

var draw = new OpenLayers.Control.DrawFeature(
    earthquakes, OpenLayers.Handler.Point);
map.addControl(draw);

function toggle() {
    if (document.getElementById("toggle-id").checked) {
        draw.activate();
    } else {
        draw.deactivate();
    }
}
document.getElementById("toggle-id").onclick = toggle;
toggle();
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
share|improve this question
    
Can you edit your question to add details of the problem? Exactly what you meant by "can not read remote file" - what error do you see, what other symptoms, what debugging have you tried? –  BradHards Mar 31 '13 at 2:59
    
Have you tried using a proxy? trac.osgeo.org/openlayers/wiki/… –  Devdatta Tengshe Mar 31 '13 at 5:17
    
your GeoRSS link does not seem to be a valid GeoRSS. –  Devdatta Tengshe Apr 1 '13 at 7:26
    
I meant that fatures does not appear on the screen. I am new in Openlayers. I have read that i have to build a proxy but i dont know about it. –  mete7 Apr 1 '13 at 14:01
    
#Devdatta Tengshe, you are wrong because when i uploaded that georss data to my host and Openlayers read it succesfully and Qgis opens it. The GeoRSS data is valid !!! #BradHards I meant that features does not appear on the screen. I am new in Openlayers. I have read about using proxy but i dont know about it. Is there anyway to work with remote located data in Openlayers. Do i have to upload all data to my host... –  mete7 Apr 1 '13 at 14:07
show 1 more comment

1 Answer 1

up vote 3 down vote accepted
+50

Try:

var map = new OpenLayers.Map({
    div: "map",
    layers: [
        new OpenLayers.Layer.OSM(),
        new OpenLayers.Layer.Vector("Vectors", {
            projection: new OpenLayers.Projection("EPSG:4326"),
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.Script({
                url: "http://query.yahooapis.com/v1/public/yql",
                params: {
                    q: "select * from xml where url='http://brainoff.com/test/rss.xml'"
                },
                format: new OpenLayers.Format.GeoRSS(),
                parseFeatures: function(data) {
                    return this.format.read(data.results[0]);
                }
            }),
            eventListeners: {
                "featuresadded": function () {
                    this.map.zoomToExtent(this.getDataExtent());
                }
            }
        })
    ]
});

adaptation of http://openlayers.org/dev/examples/cross-origin-xml.html

share|improve this answer
    
People just talk idly but you give the solution. Thanks for your help... –  mete7 Apr 4 '13 at 11:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.