[Pkg-javascript-commits] [leaflet-markercluster] 25/479: Add an example for zoomToBounds
Jonas Smedegaard
dr at jones.dk
Thu Oct 16 16:00:05 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet-markercluster.
commit 4e5c29f28a140de51d8bd3a912cd36d9b06cf407
Author: danzel <danzel at localhost.geek.nz>
Date: Tue Jul 17 14:09:45 2012 +1200
Add an example for zoomToBounds
---
example/marker-clustering-zoomtobounds.html | 64 +++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/example/marker-clustering-zoomtobounds.html b/example/marker-clustering-zoomtobounds.html
new file mode 100644
index 0000000..fff181b
--- /dev/null
+++ b/example/marker-clustering-zoomtobounds.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Leaflet debug page</title>
+
+ <link rel="stylesheet" href="../lib/leaflet-dist/leaflet.css" />
+ <!--[if lte IE 8]><link rel="stylesheet" href="../lib/leaflet-dist/leaflet.ie.css" /><![endif]-->
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="stylesheet" href="screen.css" />
+ <script src="../lib/leaflet-dist/leaflet-src.js"></script>
+
+
+ <link rel="stylesheet" href="../src/MarkerCluster.css" />
+ <link rel="stylesheet" href="../src/MarkerCluster.Default.css" />
+ <script src="../src/MarkerClusterGroup.js"></script>
+ <script src="../src/MarkerCluster.js"></script>
+</head>
+<body>
+
+ <div id="map"></div>
+ <span>Click a cluster to zoom to its bounds</span>
+
+ <script type="text/javascript">
+
+ var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
+ cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
+ cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
+ latlng = new L.LatLng(50.5, 30.51);
+
+ var map = new L.Map('map', {center: latlng, zoom: 15, layers: [cloudmade]});
+
+ var markers = new L.MarkerClusterGroup();
+
+ function populate() {
+ for (var i = 0; i < 100; i++) {
+ var m = new L.Marker(getRandomLatLng(map));
+ markers.addLayer(m);
+ }
+ return false;
+ }
+ function getRandomLatLng(map) {
+ var bounds = map.getBounds(),
+ southWest = bounds.getSouthWest(),
+ northEast = bounds.getNorthEast(),
+ lngSpan = northEast.lng - southWest.lng,
+ latSpan = northEast.lat - southWest.lat;
+
+ return new L.LatLng(
+ southWest.lat + latSpan * Math.random(),
+ southWest.lng + lngSpan * Math.random());
+ }
+
+ markers.on('click', function (a) {
+ if (a.layer instanceof L.MarkerCluster) {
+ a.layer.zoomToBounds();
+ }
+ });
+
+ populate();
+ map.addLayer(markers);
+
+ </script>
+</body>
+</html>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git
More information about the Pkg-javascript-commits
mailing list