Openlayers allows you to define the visibility of an overlay layer using a layer function:
http://dev.openlayers.org/docs/files/OpenLayers/Layer-js.html#OpenLayers...
Normally, I would set up all the layers then assign visibity to each in javascript using
layerhandle.setVisibility(false);
where layerhandle is the handle you assign when defineing the layer.
My thinking is that when I create an overlay as an array I should be able to set its visibility at the same time. so something in the array should map to the openlayers setVisibility function.
in addition, this would be good in the views filter too, as it stand now, if I make a map in the views interface and display all the content types and group them, the api will make a layer switcher overlay for each group but they are on by default. this is fine with 3 layers but when you have 10 layers, it will get old fast when you have to turn a bunch off every time you load the map, further, if I want to provide my user with settings in their profile to have overlays on and off by default, a function in the api say set_overlay_visibitly($layer_identifier,$visibiltiy ) would be pretty handy....
Just thinking for the future here.
Comments
Comment #1
dmjossel commentedSeconded.
Comment #2
phayes commentedI think we could add a property called 'visibility' and have possible values of 'on' (default), 'off', and 'locked' (on and can't be turned off)
Comment #3
spydmobile commentedgood idea, I like the idea of a admin only setting like that...
Comment #4
zzolo commentedComment #5
spydmobile commentedHi guys, I dont want to be a pain, but usability in version 1 is really affected by this. The penalty for not being able to start the map with layers on/off is that the first load will force all the data to be loaded, this particularly penalizing when dealing wms layers. If I had a voice I would use it to convince you that all versions should be able to start the layer on and off.
It also means that the map will be very ugly if you offer a bunch of layers.
Comment #6
tmcw commentedIs there any possibility that you could roll a patch for 1.x that would add this functionality? It's not incredibly straightforward to hack in, but is certainly possible in an afternoon. I, zzolo, and phayes are a little overloaded with work currently and narrowing 1.x development to bug fixes rather than any functionality changes. Obviously this is a big issue (one that 0.x already has a partial fix for), but in common use cases, it has not been a blocking problem for people, so we can't prioritize it over bug fixes.
Comment #7
spydmobile commentedThanks, I will attempt something on my end, and see what I can do. I am not skilled enough with CVS etc to make a patch in the CVS sense, but I can most certainly try and hack it in, then post my changes here.
EDIT: I tried this for 1.x and it failed. Users waiting for this in 2.x should not wait on me. Sorry...
Comment #8
zzolo commentedIt looks like layer visibility is handled in a layers_activated array? Can anyone confirm this? Line of JS that leads to this assumption (openlayers.js line 150):
Honestly, it would be really awesome if we could put this as a checkbox in the preset UI, and also if we could add weights to layers to order them.
Comment #9
tmcw commentedYeah, I think this discussion is kind of missing the fact that 2.x already has this
http://skitch.com/tmcw/nwekj/openlayers-localhost