As simple as it sounds, WMS layers from Geoserver rendered on client side via Leaflet/Openlayers have their Z-index predefined in the code itself; I was hoping to use an interface of sorts to reorder layers similar to how QGIS/ArcGIS layer ordering works.

Some idea from Leaflet Plugin enter image description here

Is there anyway to have a feature to drag and reorder instead of clicks? I couldn't find any on Openlayers. Please suggest any other alternatives.

  • 1
    In OpenLayers you can use the setZIndex() method of layers, or map.getLayers().setAt() method of the layers collection to move a layer in the layer stack. Most third party layer switchers for OpenLayers arrange their menus based only on position in the layers stack. The ol-ext layerswitcher does that. Here's a demo where you can reorder the base layers (not very useful when only one is visible!) by dragging the up/down button or, more useful if you zoom out until pirate map is visible, you can reorder pirate map and geology. – Mike Dec 6 at 13:42
  • @Mike Thank you so much for your answer! This looks promising.I don't understand why Leaflet or Openlayers do not provide this feature as a default in their API's. This is probably the most basic GIS feature there is. – Amruth Kiran Dec 7 at 4:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.