-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
36 lines (32 loc) · 1.36 KB
/
index.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Leaflet ZoomBox Control</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.1.0/dist/leaflet.css" />
<link rel="stylesheet" href="L.Control.Range.css" />
</head>
<body>
<script src="https://unpkg.com/leaflet@1.1.0/dist/leaflet-src.js"></script>
<script src="L.Control.Range.js"></script>
<div id="map" style="position: absolute; top: 0; left:0; bottom:0; right: 0;"></div>
<script>
var map = L.map('map').setView([44.07, -118.78], 6);
var layer = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png', {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
subdomains: 'abcd',
maxZoom: 10,
minZoom: 2
}).addTo(map);
var control = L.control.range({
orient: 'vertical',
value: 100
});
control.on('change input', function(e) {
console.log(e.value);
layer.setOpacity(e.value / 100);
})
map.addControl(control);
</script>
</body>
</html>