Debian Codegraph @

example/remove-geoJSON-when-spiderfied.html

raw ◀ ▶
1 Debian patch touch this file
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Leaflet debug page</title>
5
•6 <link rel="stylesheet" href="/usr/share/javascript/leafletleaflet.css" integrity="sha512-07I2e+7D8p6he1SIM+1twR5TIrhUQn9+I6yjqD53JQjFiMf8EtC93ty0/5vJTZGF8aAocvHYNEDJajGdNx1IsQ==" crossorigin="" />
7 <script src="/usr/share/javascript/leafletleaflet-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="/usr/share/javascript/leaflet/MarkerCluster.css" />
12 <link rel="stylesheet" href="/usr/share/javascript/leaflet/MarkerCluster.Default.css" />
13 <script src="/usr/share/javascript/leaflet/leaflet.markercluster-src.js"></script>
14 </head>
15 <body>
16
17 <div id="map"></div>
18 <button id="doit">Remove marker #1</button><button id="doit2">Remove marker #2</button><br/>
19 <span>New Bug. Spiderfy the cluster then click the button #1. All markers disapear, but it should remain marker #2.</span><br/>
20 <span>New Bug. Spiderfy the cluster then click the button #2. All markers disapear, but it should remain marker #1.</span><br/>
21
22 <script type="text/javascript">
23
24 var tiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
25 maxZoom: 18,
26 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
27 }),
28 latlng = new L.LatLng(50.5, 30.51);
29
30 var map = new L.Map('map', {center: latlng, zoom: 15, layers: [tiles]});
31
32 var markers = new L.MarkerClusterGroup({ disableClusteringAtZoom: 19});
33 var markersList = [];
34 var m;
35
36 geoJsonFeature = { "type": "FeatureCollection",
37 "features": [ { "type": "Feature",
38 "geometry": {
39 "type": "Point",
40 "coordinates": [30.51, 50.5]
41 }
42 }
43 ]
44 };
45 m = L.geoJson(geoJsonFeature, {
46 pointToLayer: function (feature, latlng) {
47 return L.marker(latlng);
48 }
49 });
50 markersList.push(m);
51 markers.addLayer(m);
52
53
54 geoJsonFeature = { "type": "FeatureCollection",
55 "features": [ { "type": "Feature",
56 "geometry": {
57 "type": "Point",
58 "coordinates": [30.5101, 50.5]
59 }
60 }
61 ]
62 };
63 m = L.geoJson(geoJsonFeature, {
64 pointToLayer: function (feature, latlng) {
65 return L.marker(latlng);
66 }
67 });
68 markersList.push(m);
69 markers.addLayer(m);
70
71 map.addLayer(markers);
72
73 L.DomUtil.get('doit').onclick = function () {
74 markers.removeLayer(markersList[0]);
75 };
76
77 L.DomUtil.get('doit2').onclick = function () {
78 markers.removeLayer(markersList[1]);
79 };
80
81 </script>
82 </body>
83 </html>