Making layer switcher collapsible

Created on 17 March 2023, over 1 year ago
Updated 20 March 2023, over 1 year ago

The OL3 Layerswitcher library allows the layer switcher to be collapsible. However, I do not see such an option in the 7.x-3.x-dev version of this module. Am I overlooking some setting, or can I enable this feature using the API?

By the way, the ReadMe lists the OL3 Layerswitcher library as included, but I can't find where in the module file structure it might be located.

πŸ’¬ Support request
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia sano

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sano
  • πŸ‡¬πŸ‡§United Kingdom ken-g

    Hi @sano,

    The OL3LayerSwitcher is an external library that has been incorporated into the 7.x-3.x Drupal Openlayers module.

    If you are having trouble finding the code, it is located as a plugin in the openlayers_library sub-module of the main Openlayers module.

    When this layerswitcher is added to a map, a new control appears on the map. If you hover your mouse over the control, the layerswitcher appears showing all the layers. Moving the mouse away from the control causes the layerswitcher to disappear again. Is this what you mean by "collapsible" ?

    I have checked the code, and there is already a configuration option to make the layerswitcher collapsible. It defaults to on. However, I don't this setting is used anywhere, and therefore has no effect on the actions described above.

    So, please can you explain what you mean by a layerswitcher being "collapsible", and how you would expect this feature to work ?

  • πŸ‡ΈπŸ‡°Slovakia sano

    In the attached pic I am showing my map in a default state, after the page is loaded. The layer switcher content is shown. I would expect two things:

    1. there should be a way to collapse the control into a smaller icon representing the layers in the map,
    2. the default state should be the collapsed one (other folks might wish for the opposite)

    By collapsing I mean similar behavior the attribution control works - in a default state one sees only the [ i ] icon. When clicked, the control expands to show the full attribution for the displayed map and a [>] button is also revealed by expanding, allowing user to collapse the control back.

  • πŸ‡¬πŸ‡§United Kingdom ken-g

    Thanks for sending the screen shot. I now understand the issue.

    Judging by the fact the layer switcher is shown on the left hand side of your screen, I am assuming that you are using the original openlayers layer switcher. This is not the OL3LayerSwitcher that you were asking about in the original issue.

    Why don't you try the OL3LayerSwitcher instead of the original that you are currently using ? I believe that this will immediately give you the collapsible aspect that you are requesting.

    As I explained in comment #2, once you have added the OL3LayerSwitcher to your map configuration, a new minimised control appears on the right-hand side of your map. If you then hover your mouse over the control, the layerswitcher appears showing all the layers. Moving the mouse away from the control causes the layerswitcher to disappear again.

    Is this the functionality you are looking for ?

    However, if you would still like to keep the original layerswitcher, I can probably add the collapsible aspect to it reasonably easily. Please let me know how you would like to proceed...

  • πŸ‡ΈπŸ‡°Slovakia sano

    I was not aware there is another layer switcher, besides either the one I can turn on by enabling the layer switcher component (openlayers.Control:LayerSwitcher), or the layer switcher block. How do I activate the OL3LayerSwitcher you mention? Thank you for your help.

  • πŸ‡ΈπŸ‡°Slovakia sano

    Never mind. I did not have the Openlayers library module enabled. Once I did that, I see the OL3LayerSwitcher in the control types list. I guess, this issue can be closed now. Thank you again.

  • Status changed to Fixed over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom ken-g

    Well spotted. The OL3LayerSwitcher is buried away in the Openlayers Library submodule, so once you had enabled that it should be easy enough to add to a map.

    The OL3Layers switcher automatically expands and collapses as you hover over the icon, so hopefully this provides you with an acceptable solution.

    I am closing the issue as you suggest, but please feel free to revert if the OL3LayerSwitcher does not meet your requirements.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024