51 lines
1.5 KiB
HTML
51 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Leaflet Layers Control Example</title>
|
|
<meta charset="utf-8" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<link rel="stylesheet" href="../dist/leaflet.css" />
|
|
</head>
|
|
<body>
|
|
<div id="map" style="width: 600px; height: 400px"></div>
|
|
|
|
<script src="../dist/leaflet.js"></script>
|
|
<script>
|
|
var cities = new L.LayerGroup();
|
|
|
|
L.marker([39.61, -105.02]).bindPopup('This is Littleton, CO.').addTo(cities),
|
|
L.marker([39.74, -104.99]).bindPopup('This is Denver, CO.').addTo(cities),
|
|
L.marker([39.73, -104.8]).bindPopup('This is Aurora, CO.').addTo(cities),
|
|
L.marker([39.77, -105.23]).bindPopup('This is Golden, CO.').addTo(cities);
|
|
|
|
|
|
var mbAttr = 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
|
|
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
|
|
mbUrl = 'https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png';
|
|
|
|
var grayscale = L.tileLayer(mbUrl, {id: 'examples.map-20v6611k', attribution: mbAttr}),
|
|
streets = L.tileLayer(mbUrl, {id: 'examples.map-i875mjb7', attribution: mbAttr});
|
|
|
|
var map = L.map('map', {
|
|
center: [39.73, -104.99],
|
|
zoom: 10,
|
|
layers: [grayscale, cities]
|
|
});
|
|
|
|
var baseLayers = {
|
|
"Grayscale": grayscale,
|
|
"Streets": streets
|
|
};
|
|
|
|
var overlays = {
|
|
"Cities": cities
|
|
};
|
|
|
|
L.control.layers(baseLayers, overlays).addTo(map);
|
|
</script>
|
|
</body>
|
|
</html>
|