-
Notifications
You must be signed in to change notification settings - Fork 0
/
advanced.html
48 lines (42 loc) · 1.55 KB
/
advanced.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<title>Advanced Example</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.css" />
<link rel="stylesheet" href="leaflet.groupedlayercontrol.css" />
</head>
<body>
<div id="map" style="width: 600px; height: 400px"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.js"></script>
<script src="js/leaflet.groupedlayercontrol.js"></script>
<script src="js/exampledata.js"></script>
<script>
var map = L.map('map', {
center: [39.73, -104.99],
zoom: 10,
layers: [ExampleData.Basemaps.Grayscale, ExampleData.LayerGroups.cities]
});
// Overlay layers are grouped
var groupedOverlays = {
"Landmarks": {
"Cities": ExampleData.LayerGroups.cities,
"Restaurants": ExampleData.LayerGroups.restaurants
},
};
var options = {
// Make the "Landmarks" group exclusive (use radio inputs)
exclusiveGroups: ["Landmarks"],
// Show a checkbox next to non-exclusive group labels for toggling all
groupCheckboxes: true
};
// Use the custom grouped layer control, not "L.control.layers"
var layerControl = L.control.groupedLayers(ExampleData.Basemaps, groupedOverlays, options);
map.addControl(layerControl);
// Remove and add a layer
//layerControl.removeLayer(cities);
//layerControl.addOverlay(cities, "Cities", "New Category");
</script>
</body>
</html>