| 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 |
<script src="realworld.388.js"></script> |
| 15 |
|
| 16 |
</head> |
| 17 |
<body> |
| 18 |
|
| 19 |
<div id="map"></div> |
| 20 |
<button id="doit">Zoom to marker</button> |
| 21 |
<span>When clicked we will zoom down to a marker, spiderfying if required to show it and then open its popup</span> |
| 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: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' |
| 27 |
}), |
| 28 |
latlng = L.latLng(-37.82, 175.24); |
| 29 |
|
| 30 |
var map = L.map('map', {center: latlng, zoom: 13, layers: [tiles]}); |
| 31 |
|
| 32 |
var markers = L.markerClusterGroup(); |
| 33 |
var markerList = []; |
| 34 |
|
| 35 |
function populate() { |
| 36 |
for (var i = 0; i < addressPoints.length; i++) { |
| 37 |
var a = addressPoints[i]; |
| 38 |
var title = a[2]; |
| 39 |
var marker = L.marker(L.latLng(a[0], a[1]), { title: title }); |
| 40 |
marker.bindPopup(title); |
| 41 |
markers.addLayer(marker); |
| 42 |
markerList.push(marker); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
populate(); |
| 47 |
|
| 48 |
map.addLayer(markers); |
| 49 |
|
| 50 |
document.getElementById('doit').onclick = function () { |
| 51 |
var m = markerList[Math.floor(Math.random() * markerList.length)]; |
| 52 |
markers.zoomToShowLayer(m, function () { |
| 53 |
m.openPopup(); |
| 54 |
}); |
| 55 |
}; |
| 56 |
|
| 57 |
</script> |
| 58 |
</body> |
| 59 |
</html> |