Add MIT Licence and update the readme

This commit is contained in:
danzel
2012-07-16 16:33:57 +12:00
parent 5c6520c81e
commit 9161de52cc
2 changed files with 46 additions and 5 deletions

20
MIT-LICENCE.txt Normal file
View File

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

View File

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