Debian Codegraph @

example/old-bugs/setView-doesnt-remove.html

raw
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Leaflet debug page</title>
5
6 <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-07I2e+7D8p6he1SIM+1twR5TIrhUQn9+I6yjqD53JQjFiMf8EtC93ty0/5vJTZGF8aAocvHYNEDJajGdNx1IsQ==" crossorigin="" />
7 <script src="https://unpkg.com/[email protected]/dist/leaflet-src.js" integrity="sha512-WXoSHqw/t26DszhdMhOXOkI7qCiv5QWXhH9R7CgvgZMHz1ImlkVQ3uNsiQKu5wwbbxtPzFXd1hK4tzno2VqhpA==" crossorigin=""></script>
8 <meta name="viewport" content="width=device-width, initial-scale=1.0">
9 <link rel="stylesheet" href="../screen.css" />
10
11 <link rel="stylesheet" href="../../dist/MarkerCluster.css" />
12 <link rel="stylesheet" href="../../dist/MarkerCluster.Default.css" />
13 <script src="../../src/DistanceGrid.js"></script>
14 <script src="../../src/MarkerCluster.js"></script>
15 <script src="../../src/MarkerClusterGroup.js"></script>
16 <script src="../../src/MarkerCluster.QuickHull.js"></script>
17 <script src="../../src/MarkerCluster.Spiderfier.js"></script>
18 </head>
19 <body>
20
21 <div id="map"></div>
22 <button id="doit">setView</button><br/>
23 <span>Bug <a href="https://github.com/danzel/Leaflet.markercluster/issues/63">#63</a>. Zoom down on the very left side untill markers are visible. Click the button. Scroll to the left in one go, those markers should be in clusters but the actual markers will still be visible.</span><br/>
24 <span id="time"></span>
25 <script type="text/javascript">
26
27 //Mobile does different bounds to desktop, makes the bug easier to reproduce
28 L.Browser.mobile = true;
29
30 var tiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
31 maxZoom: 18,
32 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
33 }),
34 latlng = new L.LatLng(50.5, 30.51);
35
36 var map = new L.Map('map', {center: latlng, zoom: 15, layers: [tiles]});
37
38 var markers = new L.MarkerClusterGroup();
39 var markersList = [];
40
41 function getRandomLatLng(map) {
42 var bounds = map.getBounds(),
43 southWest = bounds.getSouthWest(),
44 northEast = bounds.getNorthEast(),
45 lngSpan = northEast.lng - southWest.lng,
46 latSpan = northEast.lat - southWest.lat;
47
48 return new L.LatLng(
49 southWest.lat + latSpan * Math.random(),
50 southWest.lng + lngSpan * Math.random());
51 }
52
53 function populate(length) {
54 for (var i = 0; i < length; i++) {
55 var m = new L.Marker(getRandomLatLng(map));
56 markers.addLayer(m);
57 }
58 }
59
60 populate(1000);
61 map.addLayer(markers);
62
63 L.DomUtil.get('doit').onclick = function () {
64 map.setView(new L.LatLng(50.5, 30.525), 15);
65 };
66
67 </script>
68 </body>
69 </html>