[OpenLayers-Users] Function on loadend

Arnaud Vandecasteele arnaud.sig at gmail.com
Thu Sep 25 12:39:18 EDT 2008


Hello all,

I 'm trying to play with the OpenLayers API and do my own object.
I want to add my own function on OpenLayers.Layer.WFS to be able to draw a
graph (proportional circle) with a WFS Layer.

My problem is that in some particular function i must wait until the layer
has been loaded.
So i used the events.register("loadend") but when i used it nothings it's
return by the function and if i use a console.log in the same function i can
see the result of my function in my firebug.

Could someone explain me how to wait until the end of the layer loading and
to have a good return?

Many thanks

Arnaud


For example :
___________________________

OpenLayers.Layer.WFSchart = OpenLayers.Class(OpenLayers.Layer.WFS, {
//Some script

getTotalFeature : function() {
        //GetNumberFeatures Only When the layer
        //has been completly loaded
        this.events.register('loadend',this,function() {
            // Console.log show the good result
           console.log(this.features.length);
            return this.features.length;
        });
    }
CLASS_NAME: "OpenLayers.Layer.WFS.Chart"
});

And in my html :

var wfs2 = new OpenLayers.Layer.WFS.Chart("WFSchart",
"../featureserver/featureserver.cgi/worldPop?format=WFS", {maxFeatures:15},
{extractAttributes:true, displayInLayerSwitcher: true, maxSize :10,
maxValue:225319 });
// Console.log show undefined
console.log(wfs2.getTotalFeature());

_________________________________




-- 
--------------------------------------------------------------------
Van De Casteele Arnaud
72 Rue de la colline des camélias 97400 Saint-Denis
0262 30 67 79 - 0692 23 73 17
SIG - WebMapping - GPS embarqué
Site internet : http://geotribu.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080925/4481a6ef/attachment.html


More information about the Users mailing list