Ticket #1086 (new feature)

Opened 7 years ago

Last modified 5 years ago

LayerSwitcher updates: Layer groups, buttons for dropping moving and other features

Reported by: jachym Owned by: euzuro
Priority: minor Milestone: Addins
Component: Control.LayerSwitcher Version: 2.5
Keywords: Cc:
State: Needs Discussion

Description

Following patch implements simple way, how to order data layers (isBaseLayer == false) into groups. All map layers within one group can be made visible or hidden with one mouse click. See  http://dev.openlayers.org/sandbox/jachym/openlayers/examples/layer-groups.html for example.

The user has to specify group name as one of the layer properties, for example:

    var dm = new OpenLayers.Layer.WMS( "DM Solutions Transit",
                "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
                {layers: "rail,road",
                 transparent: "true", format: "image/png"
                },
                {                 
                  group:"Transit"
                });

Groups can be grouped to other groups. You have to use "/" (slash) mark, for group hierarchy definition:

      ...
      group: "Transit/Roads",
      ...

Attachments

LayerSwitcher.js.patch Download (10.0 KB) - added by jachym 7 years ago.
Patch, which implements layer grouping within LayerSwitcher controll.
LayerSwitcher.js.diff Download (25.8 KB) - added by jachym 7 years ago.
Patch, which implements layer grouping and some buttons for each layer within LayerSwitcher control.

Change History

Changed 7 years ago by jachym

Patch, which implements layer grouping within LayerSwitcher controll.

Changed 7 years ago by jachym

  • keywords review added

Added "review" key word

Changed 7 years ago by jachym

  • summary changed from Layer Groups to LayerSwitcher updates: Layer groups, buttons for dropping moving and other features

New version of the patch supports following features as well:

  • "buttonDropLayer" : true //activate a button to let the user drop the layer from map and layerSwitcher
  • "buttonZoom2Extent" : true //show a button to zoom to layer extent
  • "buttonOpacity" : true //show two buttons change layer opacity
  • "buttonMoveLayer" : true //show two buttons to move layers up or down in the overlay list (this could collide with your structure)

Summary for the patch changed.

Changed 7 years ago by jachym

Patch, which implements layer grouping and some buttons for each layer within LayerSwitcher control.

Changed 7 years ago by crschmidt

  • state changed from Review to Needs Discussion

I'm starting to be of the opinion that adding more functionality to the LayerSwitcher does not belong in OpenLayers trunk, but should be pursued as an addin, or in other projects like MapFish which are already pursuing these goals. I'd like to hear back from others as to whether they agree with this or not before we commit this into trunk.

(This is an 'idealogy of OpenLayers' question, not one specific to this patch.)

Changed 7 years ago by crschmidt

  • milestone changed from 2.6 Release to Addins

Changed 5 years ago by tmcw

I was just discussing this change - I know that a bunch of people would really love to see this change happen, but I understand how it can also be an Addin functionality.

I think that this might make more sense in core if isBaseLayer: true was integrated into this system, rather than this system being a level above it. So, baseLayers are an automatic group, in a way.

Beyond the win of just having another level on which to organize layers, I also think that this would lead to people being able to use more intuitive names for Overlays than just "Overlays" - I use "Data Layers", but in a lot of cases, it would be better called "Indicators" or something like "Animal Types". And, it might be possible to set better settings on such groups - like a current project has overlays with a radio-button interface, because they aren't meant to be composited. I would be willing to spend some development time doing this if we have a real spec and some idea of whether this will be in core.

Changed 5 years ago by jachym

It is now part of HSLayers - it uses ExtJS, but the logic can be copyed.  http://redmine.ccss.cz/projects/hslayers/repository/changes/trunk/source/HSLayers/Control/LayerSwitcher.js

Note: See TracTickets for help on using tickets.