Skip to content

Commit 5228a62

Browse files
alenaksuperliedman
authored andcommitted
feat(Marker.Drag): autoPan implementation (Leaflet#5651)
* feat(Marker.Drag): autoPan implementation * Adjust autoPanSpeed to 10 * Add tests for marker drag
1 parent b7cbcb3 commit 5228a62

File tree

5 files changed

+498
-0
lines changed

5 files changed

+498
-0
lines changed

debug/map/marker-autopan.html

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Leaflet debug page</title>
5+
6+
<link rel="stylesheet" href="../../dist/leaflet.css" />
7+
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9+
10+
<link rel="stylesheet" href="../css/screen.css" />
11+
12+
<script src="../leaflet-include.js"></script>
13+
</head>
14+
<body>
15+
16+
<div id="map"></div>
17+
18+
<script>
19+
map = L.map('map', { center: [0, 0], zoom: 3, maxZoom: 4 });
20+
21+
var markerAutoPan = new L.Marker([0, -10], {
22+
draggable: true,
23+
autoPan: true,
24+
title: 'AutoPan'
25+
});
26+
27+
map.addLayer(markerAutoPan);
28+
markerAutoPan.bindPopup("AutoPan");
29+
30+
31+
var markerDraggable = new L.Marker([0, 10], {
32+
title: 'Draggable'
33+
});
34+
35+
map.addLayer(markerDraggable);
36+
markerDraggable.bindPopup("Draggable");
37+
markerDraggable.dragging.enable();
38+
39+
var poly = new L.Polygon([[0, 10], [0, 15.5], [0, 50], [20, 20.5]]);
40+
map.addLayer(poly);
41+
poly.bindPopup("Polygon");
42+
43+
44+
markerDraggable.on('click', function(e) {
45+
console.log('markerDraggable click');
46+
});
47+
markerAutoPan.on('click', function(e) {
48+
console.log('markerAutoPan click');
49+
})
50+
map.on('click', function(e) {
51+
console.log('map click');
52+
});
53+
54+
poly.on('click', function(e) {
55+
console.log('poly click');
56+
});
57+
58+
var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
59+
attribution: '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
60+
}).addTo(map);
61+
</script>
62+
</body>
63+
</html>

spec/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575

7676
<!-- /layer/marker/ -->
7777
<script src="suites/layer/marker/MarkerSpec.js"></script>
78+
<script src="suites/layer/marker/Marker.DragSpec.js"></script>
7879
<script src="suites/layer/marker/Icon.DefaultSpec.js"></script>
7980

8081
<!-- /layer/vector/ -->

0 commit comments

Comments
 (0)