Skip to content

carvex21/leaflet-layerscontrol-buttons

 
 

Repository files navigation

Leaflet layerscontrol buttons

Simple and compact Leaflet layers control composed of a button for each layer, similar to the Google maps API used to use.

screenshot

Usage

After including leaflet, include these two leaflet-layerscontrol-buttons files.

<link rel="stylesheet" href="leaflet-layerscontrol-buttons.css" />
<script src="leaflet-layerscontrol-buttons.js"></script>

And use it like you would use L.Control.Layers, omitting the overlays argument:

var layersControl = L.control.layers.buttons({
    'OSM': L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'),
    'Toner': L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png'),
    'Watercolor': L.tileLayer('http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg')
}).addTo(map);

// attribution omitted for the example, remember to attribute!

About

Leaflet layers control using a set of buttons.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CSS 47.9%
  • JavaScript 38.8%
  • HTML 13.3%