[Pkg-javascript-commits] [leaflet-markercluster] 68/479: Give the everything example add/remove buttons

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:10 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 643757df40a64ffcc274de68ad0a51087cbee34d
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jul 20 16:27:50 2012 +1200

    Give the everything example add/remove buttons
---
 example/marker-clustering-everything.html | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/example/marker-clustering-everything.html b/example/marker-clustering-everything.html
index 97f023a..ebe416f 100644
--- a/example/marker-clustering-everything.html
+++ b/example/marker-clustering-everything.html
@@ -19,6 +19,8 @@
 <body>
 
 	<div id="map"></div>
+	<button id="populate">Populate 1 marker</button>
+	<button id="remove">Remove 1 marker</button>
 	<span>Mouse over a cluster to see the bounds of its children and click a cluster to zoom to those bounds</span>
 	<script type="text/javascript">
 
@@ -87,6 +89,25 @@
 
 		populate();
 		map.addLayer(markers);
+
+
+		//Ugly add/remove code
+		L.DomUtil.get('populate').onclick = function () {
+			var bounds = map.getBounds(),
+			southWest = bounds.getSouthWest(),
+			northEast = bounds.getNorthEast(),
+			lngSpan = northEast.lng - southWest.lng,
+			latSpan = northEast.lat - southWest.lat;
+			var m = new L.Marker(new L.LatLng(
+					southWest.lat + latSpan * 0.5,
+					southWest.lng + lngSpan * 0.5));
+			markersList.push(m);
+			markers.addLayer(m);
+		};
+		L.DomUtil.get('remove').onclick = function () {
+			markers.removeLayer(markersList.pop());
+		};
+
 	</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