Reputation: 725
Is there a Leaflet plugin or example for letting the user control the display order of overlay layers in a map? Turning layers on and off is working fine, but I'd like the user to be able to drag layer names within the layer control to set the Z order.
Upvotes: 2
Views: 581
Reputation: 1251
For Path class (Polygons, Polylines, etc.) there are methods 'bringToFront()' and 'bringToBack()'. You can't exactly set precise position in draw order, but iterating over layer list and calling 'bringToFront()' could be less time consuming, then re-drawing every layer (especialy if they are bigger).
Upvotes: 1