forked from Dcode-Evo/Leaflet.SmoothWheelZoom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
78 lines (65 loc) · 1.73 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.js"></script>
<script src="smooth-wheel-zoom.js"></script>
<title>Leaflet - Smooth zoom demo</title>
</head>
<style>
* {
margin: 0;
padding: 0;
}
#mapid {
width: 100vw;
height: 100vh;
}
#info_container {
position: absolute;
z-index: 999;
top: 0;
left: 50%;
margin-top: 8px;
padding: 8px;
transform: translateX(-50%);
width: 200px;
height: 64px;
background: rgba(0, 0, 0, 0.8);
color: white;
text-align: center;
}
#info_container span {
font-size: 24px;
}
</style>
<body>
<div id="mapid"></div>
<div id="info_container"></div>
<script>
const locationPos = [50.66368831946547, 5.5071615135229095];
const mymap = L.map('mapid', {
scrollWheelZoom: false,
smoothWheelZoom: true,
smoothSensitivity: 1,
zoomSnap: 0,
}).setView(locationPos, 13);
mymap.scrollWheelZoom = true;
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
}).addTo(mymap);
mymap.on('zoom', function () {
showZoom();
});
function showZoom() {
document.getElementById('info_container').innerHTML = 'zoom<br/>' + '<span>' + mymap.getZoom().toFixed(2) + '</span>';
}
showZoom();
const CircleMarker = L.circleMarker(locationPos, {
fillColor: '#0383ff',
fillOpacity: 0.5,
radius: 20,
}).addTo(mymap);
L.marker(locationPos).addTo(mymap);
</script>
</body>
</html>