2009/3/16 Didrik Pinte <[email protected]>:
> Hi list,

Hi


> We have an application that is linked to a servlet that generates a
> GeoJSON stream. In some situations, the stream is empty.
>
> Looking a Format/GeoJSON.js, I cannot find the correct way to provide a
> valid GeoJSON stream that containts no features. A FeatureCollection
> with no feature raise an error, an empty string raises an error too.
>
> What is the best practice for that kind of situation ?

Consider using OpenLayers.Protocol.HTTP.

var protocol = new OpenLayers.Protocol.HTTP({
    url: "url-to-your-service",
    format: new OpenLayers.Format.GeoJSON()
});
protocol.read({
    callback: function(response) {
        var features = response.features;
        // features will be null if the GeoJSON stream is empty
    }
});

Hope that helps,

--
Eric
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to