Debian Codegraph @

example/old-bugs/remove-when-spiderfied.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">Remove and add direct to map</button><button id="doit2">clearLayers</button><button id="doit3">removeLayers</button><br/>
23 <span>Bug <a href="https://github.com/danzel/Leaflet.markercluster/issues/54">#54</a>. Spiderfy the cluster then click the button. Should result in 2 markers right beside each other on the map.</span><br/>
24 <span>Bug <a href="https://github.com/danzel/Leaflet.markercluster/issues/53">#53</a>. Spiderfy the cluster then click the button. Spider lines remain on the map.</span><br/>
25 <span>Bug <a href="https://github.com/danzel/Leaflet.markercluster/issues/49">#49</a>. Spiderfy the cluster then click the second button. Spider lines remain on the map. Click the map to get an error.</span>
26
27 <script type="text/javascript">
28
29 var tiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
30 maxZoom: 18,
31 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
32 }),
33 latlng = new L.LatLng(50.5, 30.51);
34
35 var map = new L.Map('map', {center: latlng, zoom: 15, layers: [tiles]});
36
37 var markers = new L.MarkerClusterGroup();
38 var markersList = [];
39 var m;
40
41 m = new L.Marker([50.5, 30.51]);
42 markersList.push(m);
43 markers.addLayer(m);
44 m = new L.Marker([50.5, 30.5101]);
45 markersList.push(m);
46 markers.addLayer(m);
47
48 map.addLayer(markers);
49
50 //Ugly add/remove code
51 L.DomUtil.get('doit').onclick = function () {
52 map.removeLayer(markers);
53 map.addLayer(markersList[0]);
54 map.addLayer(markersList[1]);
55 };
56 L.DomUtil.get('doit2').onclick = function () {
57 markers.clearLayers();
58 };
59 L.DomUtil.get('doit3').onclick = function () {
60 markers.removeLayers(markersList);
61 };
62
63 </script>
64 </body>
65 </html>