-
Notifications
You must be signed in to change notification settings - Fork 31
/
index.html
76 lines (63 loc) · 1.72 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
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.6.0/leaflet.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.6.0/leaflet.js"></script>
<script src="./SmoothWheelZoom.js"></script>
<title>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>
var mymap = L.map('mapid', {
scrollWheelZoom: false,
smoothWheelZoom: true,
smoothSensitivity: 1,
}).setView([51.505, -0.09], 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> contributors'
}).addTo(mymap);
mymap.on("zoom", function () {
showZoom();
})
function showZoom(){
document.getElementById('info_container').innerHTML = "zoom<br/>" + "<span>" + mymap.getZoom().toFixed(2) + "</span>";
}
showZoom();
var CircleMarker = L.circleMarker([51.495, -0.09], {
fillColor: '#0383ff',
fillOpacity: 0.5,
radius: 20
}).addTo(mymap);
L.marker([51.515, -0.09]).addTo(mymap);
</script>
</body>
</html>