Debian Codegraph @

example/marker-clustering-pane.html

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
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="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 <script src="../dist/leaflet.markercluster-src.js"></script>
13
14 <style>
15 .myclusterA {
16 width: 40px;
17 height: 40px;
18 background-color: greenyellow;
19 text-align: center;
20 font-size: 24px;
21 }
22 .myclusterB {
23 width: 40px;
24 height: 40px;
25 background-color: red;
26 text-align: center;
27 font-size: 24px;
28 }
29
30 </style>
31 </head>
32 <body>
33
34 <div id="map"></div>
35
36 <script type="text/javascript">
37
38 var tiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
39 maxZoom: 18,
40 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
41 }),
42 latlng = L.latLng(50.5, 30.51);
43
44 var map = L.map('map', {center: latlng, zoom: 15, layers: [tiles]});
45
46 //Define a pane above the default markerPane
47 map.createPane('paneB').style.zIndex = 610;
48
49 //Create two markerClusterGroups, one in the default markerPane, one in our custom pane
50 var markersA = createMarkerClusterGroup('myclusterA');
51 var markersB = createMarkerClusterGroup('myclusterB', 'paneB');
52
53 function createMarkerClusterGroup(className, pane) {
54 var options = {
55 maxClusterRadius: 120,
56 iconCreateFunction: function (cluster) {
57 var markers = cluster.getAllChildMarkers();
58 var n = 0;
59 for (var i = 0; i < markers.length; i++) {
60 n += markers[i].number;
61 }
62 return L.divIcon({ html: n, className: className, iconSize: L.point(40, 40) });
63 },
64 //Disable all of the defaults & specify the pane:
65 spiderfyOnMaxZoom: false,
66 showCoverageOnHover: false,
67 zoomToBoundsOnClick: false
68 };
69 if (pane) {
70 options.clusterPane = pane;
71 }
72 var mcg = L.markerClusterGroup(options);
73 return(mcg);
74 }
75
76 function populate(markers) {
77 for (var i = 0; i < 100; i++) {
78 var m = L.marker(getRandomLatLng(map), { title: i });
79 m.number = i;
80 markers.addLayer(m);
81 }
82 return false;
83 }
84
85 function getRandomLatLng(map) {
86 var bounds = map.getBounds(),
87 southWest = bounds.getSouthWest(),
88 northEast = bounds.getNorthEast(),
89 lngSpan = northEast.lng - southWest.lng,
90 latSpan = northEast.lat - southWest.lat;
91
92 return L.latLng(
93 southWest.lat + latSpan * Math.random(),
94 southWest.lng + lngSpan * Math.random());
95 }
96
97 populate(markersA);
98 populate(markersB);
99 map.addLayer(markersA);
100 map.addLayer(markersB);
101
102 </script>
103 </body>
104 </html>