[Pkg-javascript-commits] [leaflet-markercluster] 35/479: Readme/Example updates
Jonas Smedegaard
dr at jones.dk
Thu Oct 16 16:00:06 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 e0bcc5e56c959ee315d53f8096b7a9ed1bf22768
Author: danzel <danzel at localhost.geek.nz>
Date: Wed Jul 18 11:55:21 2012 +1200
Readme/Example updates
---
README.md | 26 +++++++++++++++++++++++---
example/marker-clustering-everything.html | 2 +-
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 24724f4..66bed24 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Leaflet.markercluster
Provides Marker Clustering functionality for Leaflet
## Using the plugin
-See the included example for usage. Or [check it out online here](http://danzel.github.com/Leaflet.markercluster/example/marker-clustering.html)
+See the included examples for usage. Or [check out the most basic example](http://danzel.github.com/Leaflet.markercluster/example/marker-clustering.html) or the [everything example](http://danzel.github.com/Leaflet.markercluster/example/marker-clustering-everything.html).
Create a new MarkerClusterGroup, add your markers to it, then add it to the map
@@ -30,7 +30,6 @@ var markers = new L.MarkerClusterGroup({ options: {
```
### Events
-
If you register for click, mouseover, etc events on the MarkerClusterGroup you will get callbacks for both individual markers and clusters.
Set your callback up as follows to handle both cases:
@@ -44,7 +43,28 @@ markers.on('click', function (a) {
});
```
-### License
+### Getting the bounds of a cluster
+When you recieve an event from a cluster you can query it for the bounds.
+See [example/marker-clustering-convexhull.html](http://danzel.github.com/Leaflet.markercluster/example/marker-clustering-convexhull.html) for a working example.
+```javascript
+markers.on('click', function (a) {
+ if (a.layer instanceof L.MarkerCluster) {
+ map.addLayer(new L.Polygon(a.layer.getConvexHull()));
+ }
+});
+```
+### Zooming to the bounds of a cluster
+When you recieve an event from a cluster you can zoom to its bounds in one easy step.
+See [marker-clustering-zoomtobounds.html](http://danzel.github.com/Leaflet.markercluster/example/marker-clustering-zoomtobounds.html) for a working example.
+```javascript
+markers.on('click', function (a) {
+ if (a.layer instanceof L.MarkerCluster) {
+ a.layer.zoomToBounds();
+ }
+});
+```
+
+### License
Leaflet.markercluster is free software, and may be redistributed under the MIT-LICENSE.
diff --git a/example/marker-clustering-everything.html b/example/marker-clustering-everything.html
index 17b5073..97f023a 100644
--- a/example/marker-clustering-everything.html
+++ b/example/marker-clustering-everything.html
@@ -19,7 +19,7 @@
<body>
<div id="map"></div>
-
+ <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">
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
--
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