[OpenLayers-Users] Function on loadend

Christopher Schmidt crschmidt at metacarta.com
Thu Sep 25 12:43:38 EDT 2008


On Thu, Sep 25, 2008 at 04:39:18PM +0000, Arnaud Vandecasteele wrote:
> 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.

layer.events.register("loadend", layer, function() {
console.log(layer.features.length); }); 

-- Chris

> 
> 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/

> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users


-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list