[Pkg-javascript-commits] [leaflet-markercluster] 117/219: Replaced constructors by factories

Jonas Smedegaard dr at jones.dk
Sat May 7 09:39:22 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet-markercluster.

commit d5c7c946092c1b0a52244e4dc5a9725d41b7b5d0
Author: ghybs <ghybs at users.noreply.github.com>
Date:   Fri Oct 9 12:44:43 2015 +0400

    Replaced constructors by factories
    
    Replaced constructors by factories in README documentation, as proposed in #500 ([docs] Replace object constructor with factory)
---
 README.md | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 8a5fdf1..bafaaa0 100644
--- a/README.md
+++ b/README.md
@@ -21,8 +21,8 @@ Or check out the [custom example](http://leaflet.github.com/Leaflet.markercluste
 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)));
+var markers = L.markerClusterGroup();
+markers.addLayer(L.marker(getRandomLatLng(map)));
 ... Add more layers ...
 map.addLayer(markers);
 ```
@@ -37,7 +37,7 @@ By default the Clusterer enables some nice defaults for you:
 
 You can disable any of these as you want in the options when you create the MarkerClusterGroup:
 ```javascript
-var markers = new L.MarkerClusterGroup({ spiderfyOnMaxZoom: false, showCoverageOnHover: false, zoomToBoundsOnClick: false });
+var markers = L.markerClusterGroup({ spiderfyOnMaxZoom: false, showCoverageOnHover: false, zoomToBoundsOnClick: false });
 ```
 
 ### Customising the Clustered Markers
@@ -47,9 +47,9 @@ You do not need to include the .Default css if you go this way.
 You are passed a MarkerCluster object, you'll probably want to use getChildCount() or getAllChildMarkers() to work out the icon to show
 
 ```javascript
-var markers = new L.MarkerClusterGroup({
+var markers = L.markerClusterGroup({
 	iconCreateFunction: function(cluster) {
-		return new L.DivIcon({ html: '<b>' + cluster.getChildCount() + '</b>' });
+		return L.divIcon({ html: '<b>' + cluster.getChildCount() + '</b>' });
 	}
 });
 ```
@@ -99,7 +99,7 @@ When you receive an event from a cluster you can query it for the bounds.
 See [example/marker-clustering-convexhull.html](http://leaflet.github.com/Leaflet.markercluster/example/marker-clustering-convexhull.html) for a working example.
 ```javascript
 markers.on('clusterclick', function (a) {
-	map.addLayer(new L.Polygon(a.layer.getConvexHull()));
+	map.addLayer(L.polygon(a.layer.getConvexHull()));
 });
 ```
 

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