<div dir="ltr">Hi Christopher Schmidt,<br><br>And thanks for your answer but i don't understant it.<br>Indeed the console.log was here only to help to know the result of my function.<br>And when i want to use a return it awlays give me <span>undefined result like for this : </span>return this.features.length.<br>
The things that i don't understand it's how the console.log give the good result and the return anly give me an undefined result.<br><br>Arnaud<br><br><div class="gmail_quote">On Thu, Sep 25, 2008 at 4:43 PM, Christopher Schmidt <span dir="ltr"><<a href="mailto:crschmidt@metacarta.com">crschmidt@metacarta.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Thu, Sep 25, 2008 at 04:39:18PM +0000, Arnaud Vandecasteele wrote:<br>
> Hello all,<br>
><br>
> I 'm trying to play with the OpenLayers API and do my own object.<br>
> I want to add my own function on OpenLayers.Layer.WFS to be able to draw a<br>
> graph (proportional circle) with a WFS Layer.<br>
><br>
> My problem is that in some particular function i must wait until the layer<br>
> has been loaded.<br>
> So i used the events.register("loadend") but when i used it nothings it's<br>
> return by the function and if i use a console.log in the same function i can<br>
> see the result of my function in my firebug.<br>
<br>
</div>layer.events.register("loadend", layer, function() {<br>
console.log(layer.features.length); });<br>
<br>
-- Chris<br>
<div><div></div><div class="Wj3C7c"><br>
><br>
> Could someone explain me how to wait until the end of the layer loading and<br>
> to have a good return?<br>
><br>
> Many thanks<br>
><br>
> Arnaud<br>
><br>
><br>
> For example :<br>
> ___________________________<br>
><br>
> OpenLayers.Layer.WFSchart = OpenLayers.Class(OpenLayers.Layer.WFS, {<br>
> //Some script<br>
><br>
> getTotalFeature : function() {<br>
> //GetNumberFeatures Only When the layer<br>
> //has been completly loaded<br>
> this.events.register('loadend',this,function() {<br>
> // Console.log show the good result<br>
> console.log(this.features.length);<br>
> return this.features.length;<br>
> });<br>
> }<br>
> CLASS_NAME: "OpenLayers.Layer.WFS.Chart"<br>
> });<br>
><br>
> And in my html :<br>
><br>
> var wfs2 = new OpenLayers.Layer.WFS.Chart("WFSchart",<br>
> "../featureserver/featureserver.cgi/worldPop?format=WFS", {maxFeatures:15},<br>
> {extractAttributes:true, displayInLayerSwitcher: true, maxSize :10,<br>
> maxValue:225319 });<br>
> // Console.log show undefined<br>
> console.log(wfs2.getTotalFeature());<br>
><br>
> _________________________________<br>
><br>
><br>
><br>
><br>
> --<br>
> --------------------------------------------------------------------<br>
> Van De Casteele Arnaud<br>
> 72 Rue de la colline des camélias 97400 Saint-Denis<br>
> 0262 30 67 79 - 0692 23 73 17<br>
> SIG - WebMapping - GPS embarqué<br>
> Site internet : <a href="http://geotribu.net/" target="_blank">http://geotribu.net/</a><br>
<br>
</div></div>> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
> <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
<font color="#888888"><br>
<br>
--<br>
Christopher Schmidt<br>
MetaCarta<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>--------------------------------------------------------------------<br>Van De Casteele Arnaud<br>72 Rue de la colline des camélias 97400 Saint-Denis<br>0262 30 67 79 - 0692 23 73 17<br>
SIG - WebMapping - GPS embarqué<br>Site internet : <a href="http://geotribu.net/">http://geotribu.net/</a><br>
</div>