[OpenLayers-Users] How to unselect layers in layerswitcher and save in variable only the selected ones

Gery . gamejihou at hotmail.com
Thu Feb 21 05:30:00 PST 2013


Thanks a lot Lauri, I'll give a try and let you know.

Cheers,

Gery

Sent from my iBath

On Feb 21, 2013, at 1:05, "Lauri Kajan" <lauri.kajan at gmail.com> wrote:

Hi Gery,

Could you just use:
var visiblelayers = map.getLayersBy("visibility", true);

That method returns a list of layers with properties matching the given criteria.

-Lauri



On Thu, Feb 21, 2013 at 12:13 AM, Gery . <gamejihou at hotmail.com> wrote:
> Hello folks,
> Thanks to Richard Greenwood, this function shows which layer is unselected in the layerswitcher control.
> 
> map.events.register('changelayer', null, function(evt){
>        if(evt.property === "visibility") {
>           alert(evt.layer.name + " layer visibility changed to " + evt.layer.visibility );
>        }
> });
> I'm wondering how I can save in a variable array the unselected layers. For instance I have layers "a", "b", "c" in the layerswitcher, so "a" is unselected and I want "b" and "c" saved in an array like myarray = [b,c]. Then, I can loop over this array to do some processes calling only layers "b" and "c".
> 
> I'll appreciate some ideas about this, thanks in advance,
> 
> Gery
> 
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users

_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130221/44169103/attachment.html>
-------------- next part --------------
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users


More information about the Users mailing list