[OpenLayers-Users] access to object-variable-names

Jan Tappenbeck osm at tappenbeck.net
Thu Oct 20 02:53:03 EDT 2011



  Hi !

i create some layers like vlayer_1, vlayer_2, vlayer_3, ...

   map.vlayer_3 = new OpenLayers.Layer.Vector("Zuglinien");
   map.addLayer (map.vlayer_3);


now i want to iterate through the objects like vlayer_1, vlayer_2, 
vlayer_3, ...

i use following code to get the objects with

     var layerobj = map.getLayersByClass(/.*/);
     alert ('len: '+layerobj.length);

the count is ok - but how get i the names?

layerobj[i].id oder layerobj[i].name is not the right - name is the name 
in the layerpanel.

but how ???

2. question - how is the regex to select only objects with the name 
vlayer_* ??

regards Jan :-)






More information about the Users mailing list