Skip to content

Commit

Permalink
Add MIT Licence and update the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
danzel committed Jul 16, 2012
1 parent 5c6520c commit 9161de5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
20 changes: 20 additions & 0 deletions MIT-LICENCE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright 2012 David Leaver

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ Leaflet.markercluster

Provides Marker Clustering functionality for Leaflet

##Using the plugin
See the included example for usage.
## 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)

Create a new MarkerClusterGroup, add your markers to it, then add it to the map

```javascript
var markers = new L.MarkerClusterGroup();
markers.addLayer(new L.Marker(getRandomLatLng(map)));
... Add more layers ...
map.addLayer(markers);
```

For a more complete example see example/marker-clustering.html
For the complete example see example/marker-clustering.html

###Customising the Clustered Marker
### Customising the Clustered Marker
As an option to MarkerClusterGroup you can provide your own function for creating the Icon for the clustered markers.
The default implementation changes color at bounds of 10 and 100, but more advanced uses may require customising this.

Expand All @@ -26,4 +27,24 @@ var markers = new L.MarkerClusterGroup({ options: {
return new L.DivIcon({ html: '<b>' + childCount + '</b>' });
}
}});
```
```

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

```javascript
markers.on('click', function (a) {
if (a.layer instanceof L.MarkerCluster) {
console.log('cluster ' + a.layer.getAllChildMarkers().length);
} else {
console.log('marker ' + a.layer);
}
});
```

### License


Leaflet.markercluster is free software, and may be redistributed under the MIT-LICENSE.

0 comments on commit 9161de5

Please sign in to comment.