Debian Codegraph @

example/marker-clustering-singlemarkermode.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 <span>Click a cluster to zoom to its bounds</span>
19
20 <script type="text/javascript">
21
22 var tiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
23 maxZoom: 18,
24 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
25 }),
26 latlng = L.latLng(50.5, 30.51);
27
28 var map = L.map('map', {center: latlng, zoom: 15, layers: [tiles]});
29
30 var markers = L.markerClusterGroup({ singleMarkerMode: true});
31
32 function populate() {
33 for (var i = 0; i < 100; i++) {
34 var m = L.marker(getRandomLatLng(map));
35 markers.addLayer(m);
36 }
37 return false;
38 }
39 function getRandomLatLng(map) {
40 var bounds = map.getBounds(),
41 southWest = bounds.getSouthWest(),
42 northEast = bounds.getNorthEast(),
43 lngSpan = northEast.lng - southWest.lng,
44 latSpan = northEast.lat - southWest.lat;
45
46 return L.latLng(
47 southWest.lat + latSpan * Math.random(),
48 southWest.lng + lngSpan * Math.random());
49 }
50
51 markers.on('clusterclick', function (a) {
52 a.layer.zoomToBounds();
53 });
54
55 populate();
56 map.addLayer(markers);
57
58 </script>
59 </body>
60 </html>