On Sunday, February 6, 2011, Rossko <[email protected]> wrote:
>
>> Can you explain why it makes a difference to iterate in this way?
>
> map.layers isn't an array

map.layers is a JavaScript Array. What makes you say it's not?

>  - treat it more like a stack.   When removeLaver
> is used on the first layer, the stack collapses, what was layer[1] becomes
> the new layer[0]

Yes.

Let's assume we have map.layers equal [l1, l2, l3], and we use

for(var i=0; i<map.layers.length; i++) {
    map.removeLayer(map.layers[i]);
}

At iteration #1 (i=0) l1 is removed. At iteration #2 (i=1) l3 is
removed, and the iteration process stops with l2 still in the
map.layers array.

>
> --
> View this message in context: 
> http://osgeo-org.1803224.n2.nabble.com/Map-layers-doesn-t-seem-to-contain-all-layers-tp5996448p5997440.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [email protected]
http://www.camptocamp.com
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to