[OpenLayers-Dev] Hiding Layers from the Layer Switcher
Christopher Schmidt
crschmidt at metacarta.com
Wed Jul 18 13:02:24 EDT 2007
On Wed, Jul 18, 2007 at 12:52:53PM -0400, Peterson Eric-EEP002 wrote:
> What I would REALLY like is some way to merge both markers and vectors
> together into a single layer, so that when I select/deselect that layer
> in the Layer Switcher, both markers and vectors appear/disappear
> concurrently. But I realize that due to the architecture of OL, it might
> not be possible to do that.
In trunk, it is possible to symbolize a 'point' as an icon, so you could
essentially achieve this goal. However, you've asked about 2.4, so I'll
continue with more information on that below.
> Alternately, I could achieve the result I want if the following
> additions were made to the layer code:
>
> 1. Have a property associated with a layer that causes it to appear in
> the Layer Switcher list. This could be set as an option while
> constructing a new Layer object, and the Layer Switcher could pay
> attention to this property when generating the layer form.
displayInLayerSwitcher option on the layer:
http://dev.openlayers.org/apidocs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.displayInLayerSwitcher
> 2. When a layer is selected or deselected in the Layer Switcher, trigger
> a "showlayer" or "hidelayer" event.
The event you are talking about is the 'changelayer' event, on the Map
object. This event fires any time a layer is changed, and you can then
loop through the layers and call:
http://dev.openlayers.org/apidocs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.getVisibility
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Dev
mailing list