[OpenLayers-Dev] Hiding Layers from the Layer Switcher

Peterson Eric-EEP002 Eric.Peterson at motorola.com
Wed Jul 18 12:52:53 EDT 2007


I have a problem that I don't know how to solve ... I've poked around in
the OL code, and I can't figure out how to do what I want. Can anyone
here recommend a course of action?

I am working on developing a tracking application which shows the tracks
of multiple individuals on a single map. The track for a single
individual consists of a set of positions shown by various icons
connected in order by a line. Each position may need to be shown using a
different icon, depending upon some other data collected while reading
the location.

In my current implementation, I have the markers in one layer and the
line connecting the markers in another layer, which works great and
gives me exactly the visual presentation I want. However, since there
are two layers, there are two separate check boxes in the Layer Switcher
control. This is confusing for the user, since logically it makes the
most sense to have one layer (and consequently one checkbox) associated
with one individual.

The only way I could think of to merge the two layers together would be
to draw polygons in the line layer instead of placing icons/markers in a
separate marker layer.

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.

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.

2. When a layer is selected or deselected in the Layer Switcher, trigger
a "showlayer" or "hidelayer" event. That way, when the marker layer is
shown/hidden, the showlayer/hidelayer event handler for the marker layer
could cause the corresponding line layer to be shown/hidden.

So, is there some way to achieve this in OL 2.4? Or should I go start
modifying the code myself?

Thanks!

-eP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20070718/dfe20eea/attachment.html


More information about the Dev mailing list