Materialize CSS with multiple checkboxes using Leaflet web-mapping overlays - Javascript Leaflet

Javascript examples for Leaflet:Map

Description

Materialize CSS with multiple checkboxes using Leaflet web-mapping overlays

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="http://code.jquery.com/jquery-2.2.4.js"></script> 
      <link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"> 
      <script type="text/javascript" src="https://unpkg.com/leaflet@1.0.3/dist/leaflet-src.js"></script> 
      <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/css/materialize.css"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/js/materialize.js"></script> 
      <script type="text/javascript" src="https://fonts.googleapis.com/icon?family=Material+Icons"></script> 
      <style id="compiled-css" type="text/css">

#map {/*from w w w .j a  va2 s.  com*/
   height: 500px;
}
input[type="checkbox"].leaflet-control-layers-selector {
   position: inherit;
   left: inherit;
   opacity: inherit;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
var map = L.map("map");
L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png").addTo(map);
map.setView([48.85, 2.35], 12);
var myItems = new L.LayerGroup();
for (var i = 0; i < 50; i += 1) {
   L.marker(getRandomLatLng()).addTo(myItems);
}
var overlays = {
    Items: myItems
};
L.control.layers(null, overlays, {
   collapsed: false
}).addTo(map);
function getRandomLatLng() {
   return [
     48.8 + 0.1 * Math.random(),
    2.25 + 0.2 * Math.random()
  ];
}
    }

      </script> 
   </head> 
   <body> 
      <div id="map"></div> 
      <p> Test checkbox </p> 
      <input type="checkbox">
      <span>Items</span> 
      <br> 
      <input type="checkbox" id="test">
      <label for="test">Items</label>  
   </body>
</html>

Related Tutorials