> Wrap your function in anonymous instead.

> layers[0].events.register("loadend", layers[0], function(evt){
>   //do what you have to do here...
>    selectFeature(layers[0],oFeatures[0].fid));
> });
> 

Well, the use case is a bit more complicated.  I calculate initial
bounds for a feature then select that feature.  Then if my feature array
has more than one element I iterate through it and then features don't
get selected :

if(oFeatures && oFeatures.length > 0)                  

{
     var bounds = oFeatures[0].geometry.getBounds();
        layers[0].events.register("loadend", layers[0], function(){
        selectFeature(layers[0],oFeatures[0].fid);                              
                                               });

        for(var i = 1; i<oFeatures.length;++i)
                      {         
                        bounds.extend(oFeatures[i].geometry.getBounds());

                        layers[0].events.register("loadend", layers[0], 
function(){
                           selectFeature(layers[0],oFeatures[i].fid);});
    


I guess the event is triggered only once so iterating makes no sense ?
I thought it was the case so I just called the function directly in the
for like

selectFeature(layers[0],oFeatures[i].fid);

but that didn't work either probably because the code gets executed
before the loadend was fired.  Do I have to set up an explicit delay
here or somehow bubble the event ?

TIA,

Yves

_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to