[OpenLayers-Users] Reporting creation errors for Vector/GeoRSS layers

Andreas Hocevar ahocevar at opengeo.org
Mon Oct 31 10:27:53 EDT 2011


On Oct 28, 2011, at 16:35 , Tito, Joseph wrote:

> Andreas,
> 
> Do you have any code samples that could help me do this?

Something like this (untested):

var vectors = new OpenLayers.Layer.Vector("GeoRSS", {
    strategies: [new OpenLayers.Strategy.Fixed()],
    protocol: new OpenLayers.Protocol.HTTP({
        url: "http://yoursite.com/path/to/your/GeoRSS",
        format: new OpenLayers.Format.GeoRSS()
    }),
    eventListeners: {
        loadend: function() {
            if (vectors.features.length === 0) {
                alert("No features were loaded. Is your GeoRSS file valid?");
            }
        }
    }
});

Andreas.

> 
> Joe
> 
> -----Original Message-----
> From: openlayers-users-bounces at lists.osgeo.org [mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of Andreas Hocevar
> Sent: Thursday, October 27, 2011 5:46 AM
> To: Tito, Joseph
> Cc: openlayers-users at lists.osgeo.org
> Subject: Re: [OpenLayers-Users] Reporting creation errors for Vector/GeoRSS layers
> 
> We don't have error handling for this on the library level. But what you could do is register for the layer's loadend event and check for layer.features.length. You could notify the user when the number of features is zero.
> 
> Andreas.
> 
> On Oct 26, 2011, at 18:20 , Tito, Joseph wrote:
> 
>> Is it possible to recover error messages in the following scenarios:
>> 
>> 1)      A vector layer is created from a KML file in which the KML file is corrupted.
>> 2)      A GeoRSS layer is created from a GeoRSS file in which the file is corrupted.
>> 
>> I'm trying to report errors to my users if they supply a file that is corrupted.
>> 
>> Joe Tito
>> 
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> 
> -- 
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
> 
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users

-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list