<div dir="ltr">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 graph (proportional circle) with a WFS Layer.<br>
<br>My problem is that in some particular function i must wait until the layer has been loaded. <br>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.<br>
<br>Could someone explain me how to wait until the end of the layer loading and 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", "../featureserver/featureserver.cgi/worldPop?format=WFS", {maxFeatures:15}, {extractAttributes:true, displayInLayerSwitcher: true, maxSize :10, maxValue:225319 }); <br>
// Console.log show <span class="objectBox objectBox-text">undefined </span> <br>console.log(wfs2.getTotalFeature());<br><br>_________________________________<br><br><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>