0

I want to know how can I set a "selector layer" (L.Control.Layers) outside the container in Leaflet. Like this screenshot of an OpenLayers application:

enter image description here

PolyGeo
  • 65,136
  • 29
  • 109
  • 338

1 Answers1

0

My solution is like this:

Since you want to place it outside the map. you have to create a div and give it an id so that it can be called later.

  1. Create a div e.g. <div id='jpt'></div> in the body of HTML and use css to position it.

    <style> #jpt { position : absolute; top : 10px; right : 200px; } </style

After that in the scripts

  1. Initialize layer control. c=L.control.layers(baseLayers, overlays) and then
  2. Add to map c.addTo(map)
  3. Append it to previous div $('#jpt').append(c.onAdd(map))

this will show 2 controls so

  1. Hide Control inside map by adding $('.leaflet-top.leaflet-right').hidden = true at the end of script just before </script>
neogeomat
  • 8,380
  • 3
  • 52
  • 91