3845 |
idir |
1 |
<!DOCTYPE html>
|
|
|
2 |
<html lang="en">
|
|
|
3 |
|
|
|
4 |
<head>
|
|
|
5 |
|
|
|
6 |
<meta charset="UTF-8">
|
|
|
7 |
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
8 |
|
|
|
9 |
<title>Leaflet.GestureHandling Example</title>
|
|
|
10 |
|
|
|
11 |
<!-- Leaflet -->
|
|
|
12 |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
|
|
|
13 |
crossorigin=""/>
|
|
|
14 |
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
|
|
|
15 |
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
|
|
|
16 |
crossorigin=""></script>
|
|
|
17 |
|
|
|
18 |
<!-- Leaflet Gesture Handling -->
|
|
|
19 |
<link rel="stylesheet" href="../dist/leaflet-gesture-handling.css" type="text/css">
|
|
|
20 |
<script src="../dist/leaflet-gesture-handling.js"></script>
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
<style>
|
|
|
24 |
html, body {
|
|
|
25 |
padding:0;
|
|
|
26 |
margin:0;
|
|
|
27 |
}
|
|
|
28 |
body {
|
|
|
29 |
font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
|
|
|
30 |
background-color: #fff;
|
|
|
31 |
color: #222;
|
|
|
32 |
}
|
|
|
33 |
.content {
|
|
|
34 |
padding:20px;
|
|
|
35 |
}
|
|
|
36 |
header, .arrows {
|
|
|
37 |
text-align: center;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
#map {
|
|
|
41 |
width:100%;
|
|
|
42 |
height:600px;
|
|
|
43 |
}
|
|
|
44 |
</style>
|
|
|
45 |
|
|
|
46 |
</head>
|
|
|
47 |
|
|
|
48 |
<body>
|
|
|
49 |
<header>
|
|
|
50 |
<h1>Leaflet.GestureHandling</h1>
|
|
|
51 |
</header>
|
|
|
52 |
<div class="content">
|
|
|
53 |
<p>Try scrolling down the page.</p>
|
|
|
54 |
<p>Normally you'd get to the map then find the map starts zooming or panning.</p>
|
|
|
55 |
<p>If there's nothing outside the map to get a grip on you could find yourself trapped in the map, unable to scroll the page up or down.</p>
|
|
|
56 |
<div class="arrows">
|
|
|
57 |
<br>⇣<br><br>⇣<br><br>⇣<br><br>⇣<br><br>⇣<br><br>⇣<br><br>
|
|
|
58 |
</div>
|
|
|
59 |
</div>
|
|
|
60 |
<div id="map"></div>
|
|
|
61 |
<div class="content">
|
|
|
62 |
<p>But Leaflet.GestureHandling prevented that from happening.</p>
|
|
|
63 |
<b>On Desktop</b>
|
|
|
64 |
<ul>
|
|
|
65 |
<li>The map ignores the mouse scroll wheel.</li>
|
|
|
66 |
<li>The user is prompted to use ctrl+scroll to zoom the map.</li>
|
|
|
67 |
</ul>
|
|
|
68 |
|
|
|
69 |
<b>On Mobile/Touch enabled devices</b>
|
|
|
70 |
<ul>
|
|
|
71 |
<li>The map ignores single fingered dragging. </li>
|
|
|
72 |
<li>The user is prompted to use two fingers to pan the map.</li>
|
|
|
73 |
</ul>
|
|
|
74 |
|
|
|
75 |
<p>It brings the basic functionality of <a href="https://developers.google.com/maps/documentation/javascript/examples/interaction-cooperative">Google Maps Gesture Handling</a> into Leaflet.</p>
|
|
|
76 |
</div>
|
|
|
77 |
<hr/>
|
|
|
78 |
<div class="content">
|
|
|
79 |
<div class="arrows">
|
|
|
80 |
<p>
|
|
|
81 |
<a href="https://github.com/elmarquis/Leaflet.GestureHandling/">View this project on Github</a>
|
|
|
82 |
</p>
|
|
|
83 |
<br/>⇡<br><br>⇡<br><br>⇡<br><br>⇡<br><br>⇡<br><br>⇡<br><br>
|
|
|
84 |
</div>
|
|
|
85 |
</div>
|
|
|
86 |
|
|
|
87 |
</ul>
|
|
|
88 |
</body>
|
|
|
89 |
|
|
|
90 |
<script>
|
|
|
91 |
var map = L.map("map", {
|
|
|
92 |
center: [-25.2702, 134.2798],
|
|
|
93 |
zoom: 3,
|
|
|
94 |
gestureHandling: true
|
|
|
95 |
});
|
|
|
96 |
|
|
|
97 |
var OpenStreetMap_Mapnik = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
|
98 |
maxZoom: 19,
|
|
|
99 |
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
|
|
100 |
}).addTo(map);
|
|
|
101 |
|
|
|
102 |
//Add markers
|
|
|
103 |
var marker = new L.marker([-25.2702, 134.2798])
|
|
|
104 |
.bindPopup("Example Popup")
|
|
|
105 |
.addTo(map);
|
|
|
106 |
|
|
|
107 |
</script>
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
</html>
|