-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathexample.html
More file actions
55 lines (45 loc) · 1.28 KB
/
example.html
File metadata and controls
55 lines (45 loc) · 1.28 KB
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
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example</title>
<link rel="stylesheet" href="node_modules/leaflet/dist/leaflet.css"/>
<script src="node_modules/leaflet/dist/leaflet.js"></script>
<script src="src/ActiveLayers.js"></script>
<script src="test/TestLayers.js"></script>
<style>
#map {
width: 640px;
height: 480px;
}
</style>
</head>
<body>
<div id="map"></div>
<button id="showActiveOverlayLayers">Console Active Overlay layers</button>
</body>
<script>
(function () {
var map = L.map('map', {
center:new L.LatLng(39.73, -104.99),
zoom:10,
layers:testLayers.map
})
map.on('overlayadd', function () {
console.log(Object.keys(control.getActiveOverlayLayers()).length);
});
var control = L.control.activeLayers(testLayers.base, testLayers.overlay)
control.addTo(map)
document.getElementById('showActiveOverlayLayers').onclick = function () {
var currentActiveLayers = control.getActiveOverlayLayers()
var currentLayerList = [];
for (var layer in currentActiveLayers) {
if (currentActiveLayers.hasOwnProperty(layer)) {
currentLayerList.push(currentActiveLayers[layer])
}
}
console.log(currentLayerList)
}
})()
</script>
</html>