nl_tokens: Zoom : Zoom to start adding at ( Pass this . _maxZoom to start at the bottom )
pl_tokens: function ( layer , zoom ) { var gridClusters = this . _gridClusters , gridUnclustered = this . _gridUnclustered , markerPoint , z ; if ( this . options . singleMarkerMode ) { layer . options . icon = this . options . iconCreateFunction ( { getChildCount : function ( ) { return 1 ; } , getAllChildMarkers : function ( ) { return [ layer ] ; } } ) ; } //Find the lowest zoom level to slot this one in for ( ; zoom >= 0 ; zoom -- ) { markerPoint = this . _map . <mask> ( layer . getLatLng ( ) , zoom ) ; // calculate pixel position //Try find a cluster close by var closest = gridClusters [ zoom ] . getNearObject ( markerPoint ) ; if ( closest ) { closest . _addChild ( layer ) ; layer . __parent = closest ; return ; } //Try find a marker close by to form a new cluster with closest = gridUnclustered [ zoom ] . getNearObject ( markerPoint ) ; if ( closest ) { var parent = closest . __parent ; if ( parent ) { this . _removeLayer ( closest , false ) ; } //Create new cluster with these 2 in it var newCluster = new L . MarkerCluster ( this , zoom , closest , layer ) ; gridClusters [ zoom ] . addObject ( newCluster , this . _map . project ( newCluster . _cLatLng , zoom ) ) ; closest . __parent = newCluster ; layer . __parent = newCluster ; //First create any new intermediate parent clusters that don't exist var lastParent = newCluster ; for ( z = zoom - 1 ; z > parent . _zoom ; z -- ) { lastParent = new L . MarkerCluster ( this , z , lastParent ) ; gridClusters [ z ] . addObject ( lastParent , this . _map . project ( closest . getLatLng ( ) , z ) ) ; } parent . _addChild ( lastParent ) ; //Remove closest from this zoom level and any above that it is in, replace with newCluster for ( z = zoom ; z >= 0 ; z -- ) { if ( ! gridUnclustered [ z ] . removeObject ( closest , this . _map . project ( closest . getLatLng ( ) , z ) ) ) { break ; } } return ; } //Didn't manage to cluster in at this zoom, record us as a marker here and continue upwards gridUnclustered [ zoom ] . addObject ( layer , markerPoint ) ; } //Didn't get in anything, add us to the top this . _topClusterLevel . _addChild ( layer ) ; layer . __parent = this . _topClusterLevel ; return ; }