[OpenLayers-Users] Getting featurecollection from GeoJSON?

Christian Schanz christian.schanz at gmail.com
Fri Oct 2 17:00:22 EDT 2009


Hello,

I need a function that returns a featurecollection which is created  
from a GeoJSON.
So I think that I need to do something like the following:

function getGeoJSON() {
     var featurecollection;
     function handler(request) {
         //TODO: What to do here?
     }
     var request = OpenLayers.Request.GET( {
             url: "http://path/to/my/GeoJSON",
             callback: handler
     });
     return featurecollection;
}

But how exactly should the handler look like?
I have tried to add something like
     featurecollection = request.responseText;
to the handler but then I get no features returned at all.

And as a second question: Should my GeoJSON generating server insert a  
mime-type at the beginning of the
response or is this not needed?

Thanks a lot,
   Christian



More information about the Users mailing list