[Pkg-javascript-commits] [leaflet-markercluster] 248/479: make zoomToShowLayer choose a random marker

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:36 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 68401741f156cf9040655186468ef29e3d238c78
Author: danzel <danzel at localhost.geek.nz>
Date:   Thu Sep 20 11:28:40 2012 +1200

    make zoomToShowLayer choose a random marker
---
 example/marker-clustering-zoomtoshowlayer.html | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/example/marker-clustering-zoomtoshowlayer.html b/example/marker-clustering-zoomtoshowlayer.html
index 9b6f90b..2b35229 100644
--- a/example/marker-clustering-zoomtoshowlayer.html
+++ b/example/marker-clustering-zoomtoshowlayer.html
@@ -31,8 +31,8 @@
 		var map = new L.Map('map', {center: latlng, zoom: 13, layers: [cloudmade]});
 
 		var markers = new L.MarkerClusterGroup();
+		var markerList = [];
 
-		var lastMarker;
 		function populate() {
 			for (var i = 0; i < addressPoints.length; i++) {
 				var a = addressPoints[i];
@@ -40,7 +40,7 @@
 				var marker = new L.Marker(new L.LatLng(a[0], a[1]), { title: title });
 				marker.bindPopup(title);
 				markers.addLayer(marker);
-				lastMarker = marker;
+				markerList.push(marker);
 			}
 		}
 
@@ -49,8 +49,9 @@
 		map.addLayer(markers);
 
 		document.getElementById('doit').onclick = function () {
-			markers.zoomToShowLayer(lastMarker, function () {
-				lastMarker.openPopup();
+			var m = markerList[Math.floor(Math.random() * markerList.length)];
+			markers.zoomToShowLayer(m, function () {
+				m.openPopup();
 			});
 		};
 

-- 
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