[OpenLayers-Users] Function on loadend

Arnaud Vandecasteele arnaud.sig at gmail.com
Thu Sep 25 13:53:05 EDT 2008


Hi Christopher Schmidt,

And thanks for your answer but i don't understant it.
Indeed the console.log was here only to help to know the result of my
function.
And when i want to use a return it awlays give me undefined result like for
this : return this.features.length.
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.

Arnaud

On Thu, Sep 25, 2008 at 4:43 PM, Christopher Schmidt <
crschmidt at metacarta.com> wrote:

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



-- 
--------------------------------------------------------------------
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/6848114a/attachment.html


More information about the Users mailing list