[OpenLayers-Users] Capture empty result from wfs protocol

Zer zer_matt at hotmail.com
Thu Jun 10 17:26:43 EDT 2010


Hi users,

I have a vector layer that shows features fetched from Geoserver using fixed
strategy and wfs protocol together with a filter. Works just fine! 

I then use wfsParcelLayer.events.on and a function on the featuresadded
event to zoom in to the feature. That works fine too. 

However, sometimes the filter returns no hits, witch is ok. I would then
like to show a message to inform the user that there where no hits. I tried
to do that using the same event I use when zooming in to the feature, but
since no features are added, the event never fires. I also tried the
'beforefeaturesadded' event, but the result is (of course) the same. 

How can I capture the result to check there are any features or not in the
result? Is there a callback function that I can use in the wfs protocol?

I've added some of my code here.

Thanks,

-ZM


wfsLayer = new OpenLayers.Layer.Vector("Vector"), {
        strategies: [new OpenLayers.Strategy.Fixed({
            preload: false
        })],
        styleMap: vectorStyleMap,
        protocol: new OpenLayers.Protocol.WFS({
            version: "1.1.0",
            extractAttributes: true,
            filter: filter,
            ....

wfsLayer.events.on({
        featuresadded: function(event) {
            map.zoomToExtent(wfsLayer.getDataExtent
        }
    });
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Capture-empty-result-from-wfs-protocol-tp5165411p5165411.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list