2011-10-14 02:31:50 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Leaflet Layers Control Example</title>
|
|
|
|
<meta charset="utf-8" />
|
2012-02-14 23:02:29 +08:00
|
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
2011-10-14 02:31:50 +08:00
|
|
|
<link rel="stylesheet" href="../dist/leaflet.css" />
|
|
|
|
<!--[if lte IE 8]><link rel="stylesheet" href="../dist/leaflet.ie.css" /><![endif]-->
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="map" style="width: 600px; height: 400px"></div>
|
|
|
|
|
|
|
|
<script src="../dist/leaflet.js"></script>
|
2011-10-27 21:37:48 +08:00
|
|
|
<script>
|
|
|
|
var littletonMarker = new L.Marker(new L.LatLng(39.61, -105.02)).bindPopup("This is Littleton, CO."),
|
|
|
|
denverMarker = new L.Marker(new L.LatLng(39.74, -104.99)).bindPopup("This is Denver, CO."),
|
|
|
|
auroraMarker = new L.Marker(new L.LatLng(39.73, -104.8)).bindPopup("This is Aurora, CO."),
|
|
|
|
goldenMarker = new L.Marker(new L.LatLng(39.77, -105.23)).bindPopup("This is Golden, CO.");
|
|
|
|
|
2011-10-22 00:46:44 +08:00
|
|
|
var citiesLayer = new L.LayerGroup();
|
2011-10-27 21:37:48 +08:00
|
|
|
|
|
|
|
citiesLayer.addLayer(littletonMarker);
|
|
|
|
citiesLayer.addLayer(denverMarker);
|
|
|
|
citiesLayer.addLayer(auroraMarker);
|
|
|
|
citiesLayer.addLayer(goldenMarker);
|
|
|
|
|
2012-06-21 20:14:15 +08:00
|
|
|
var cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
|
|
|
cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/{styleId}/256/{z}/{x}/{y}.png';
|
2011-10-27 21:37:48 +08:00
|
|
|
|
2012-06-21 20:14:15 +08:00
|
|
|
var minimal = new L.TileLayer(cloudmadeUrl, {styleId: 22677, attribution: cloudmadeAttribution}),
|
|
|
|
midnightCommander = new L.TileLayer(cloudmadeUrl, {styleId: 999, attribution: cloudmadeAttribution}),
|
|
|
|
motorways = new L.TileLayer(cloudmadeUrl, {styleId: 46561, attribution: cloudmadeAttribution});
|
2011-10-27 21:37:48 +08:00
|
|
|
|
|
|
|
var map = new L.Map('map', {center: new L.LatLng(39.73, -104.99), zoom: 10, layers: [minimal, motorways, citiesLayer]});
|
|
|
|
|
|
|
|
var baseMaps = {
|
|
|
|
"Minimal": minimal,
|
|
|
|
"Night View": midnightCommander
|
|
|
|
};
|
|
|
|
|
|
|
|
var overlayMaps = {
|
|
|
|
"Motorways": motorways,
|
|
|
|
"Cities": citiesLayer
|
|
|
|
};
|
|
|
|
|
|
|
|
layersControl = new L.Control.Layers(baseMaps, overlayMaps);
|
|
|
|
|
|
|
|
map.addControl(layersControl);
|
2011-10-14 02:31:50 +08:00
|
|
|
</script>
|
|
|
|
</body>
|
2012-02-14 23:02:29 +08:00
|
|
|
</html>
|