beholder avatar beholder committed 8639e55

Update to 1.1 version.
Fixed bug with style index.
Rename claster to cluster.

Comments (0)

Files changed (4)

 - `min_size` — минимальный размер кластера *[2]*
 - `centered` — вычислять ли центр кластеров по точкам (медленнее, но точнее) *[false]*
 - `batch` — размер шага при вычислении кластеров (можно уменьшить при тормозах или для IE) *[400]*
-- `style` — объект для задания стиля метки кластера
+- `imagePath` — URL иконки (начало шаблона иконки) группы маркеров *[http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m]*
+- `imageExtension` — расширение файла иконки группы маркеров *[.png]*
+- `imageSizes` — массив размеров иконок (если иконка не зависит от количества маркеров, нужно передавать массив из одного размера) *[53, 56, 66, 78, 90]*
+- `printable` — делать ли иконки печатаемыми при отключенной печати фона *[false]*
+- `styles` — массив объектов для задания стиля метки кластера, объект вида:
   - `style.icon` — картинка иконки для кластера
   - `style.height` — высота иконки *[52]*
   - `style.width` — ширина иконки *[53]*
   - `style.offset` — массив с отступами для привязки иконки *[[0, 0]]*
   - `style.textColor` — цвет текста подписи *[#000000]*
   - `style.textSize` — размер шрифта *[11]*
-  - `style.printable` — делать ли иконки печатаемыми при отключенной печати фона *[false]*
 
-Автор: [Александр Шабуневич](http://aether.ru/), 2011
+
+История изменений
+-----------------
+
+- 1.1 - Добавлена возможность задавать разные иконки в зависимости от количества маркеров, исправлены баги. Спасибо [Neyasut](https://bitbucket.org/neyasut)
+
+
+Автор: [Александр Шабуневич](http://aether.ru/), 2012
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.

yandex.clusterer.js

 /**
  * @name YandexClusterer for Yandex Maps.
- * @version 1.0.0 [August 13, 2011]
+ * @version 1.1.0 [March 02, 2012]
  * @author Alexander Shabunevich [http://aether.ru]
  * http://beholder.bitbucket.org/yandex.clusterer/
  *
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 /**
  * Clusterer main class.
  * Init only once for each map.
   this.min_size = opts.min_size || 2;
   this.centered = opts.centered || false;
   this.batch = opts.batch || 400;
-  
+
   this.imagePath_ = opts.imagePath || YandexClusterer.IMAGE_PATH;
   this.imageExtension_ = opts.imageExtension || YandexClusterer.IMAGE_EXTENSION;
   this.imageSizes_ = opts.imageSizes || YandexClusterer.IMAGE_SIZES;
 
-  this.styles = opts.styles || this.generateClasterStyles();
+  this.styles = opts.styles || this.generateClusterStyles();
   this.printable = opts.printable || false;
   // check if there are previous events - remove them
   if (this.map._yandexClustererEvents) {
 };
 
 /**
- * Return style for claster depending on it's count of markers.
+ * Return style for cluster depending on it's count of markers.
  * @param {YandexCluster} cluster object
- * @return {Object} style for claster
+ * @return {Object} style for cluster
  */
-YandexClusterer.prototype.getClasterStyle = function (cluster) {
+YandexClusterer.prototype.getClusterStyle = function (cluster) {
   return this.styles[cluster.getIconStyleIndex(this.getStylesCount())];
 };
 
 /**
- * Generate styles for different claster size.
+ * Generate styles for different cluster size.
  * @return {Array<Object>} generated set of styles
  */
-YandexClusterer.prototype.generateClasterStyles = function () {
+YandexClusterer.prototype.generateClusterStyles = function () {
   var styles = [];
   for (var i = 0; i < this.getStylesCount(); i++) {
     styles.push(this.genStyleForIndex(i));
 
 /**
  * Generate style for specified style index.
- * used by YandexClusterer.generateClasterStyles()
+ * used by YandexClusterer.generateClusterStyles()
  * @param {number} index - index of style
- * @return {Object} generated style 
+ * @return {Object} generated style
  */
 YandexClusterer.prototype.genStyleForIndex = function (index) {
   var size = this.imageSizes_[index];
-  var iconPath = this.imagePath_ + (index + 1) + this.imageExtension_; 
+  var iconPath = this.imagePath_ + (index + 1) + this.imageExtension_;
   var style = {
     icon: iconPath,
     height: size,
     textColor: '#000000',
     textSize: 11
   };
-  return style; 
+  return style;
 };
 
 /**
- * Return styles count of clasterer.
+ * Return styles count of clusterer.
  */
 YandexClusterer.prototype.getStylesCount = function() {
   return this.imageSizes_.length;
  *
  * @param {YandexClusterer} Associated Yandex clusterer class.
  */
-function YandexCluster(clasterOwner) {
-  this.clustererObject = clasterOwner;
-  this.yandexObjectManager = clasterOwner.yandexObjectManager;
-  this.map = clasterOwner.map;
+function YandexCluster(clusterOwner) {
+  this.clustererObject = clusterOwner;
+  this.yandexObjectManager = clusterOwner.yandexObjectManager;
+  this.map = clusterOwner.map;
   this.center = null;
   this.markers = [];
   this.markers_bounds = new YMaps.GeoCollectionBounds();
   this.bounds = null;
-  this.min_size = clasterOwner.min_size;
+  this.min_size = clusterOwner.min_size;
   this.point = null;
 }
 
   return true;
 }
 
-YandexCluster.prototype.getClasterBounds = function() {
+YandexCluster.prototype.getClusterBounds = function() {
   return this.markers_bounds;
 };
 
     var template = new YMaps.Template('<div style="cursor:pointer;position:relative;line-height:$[style.iconStyle.size.y]px;height:$[style.iconStyle.size.y]px;width:$[style.iconStyle.size.x]px;text-align:center;background:url($[style.iconStyle.href]) no-repeat;font-weight:bold;font-size:$[textSize|12]px;color:$[textColor|#000]">$[markersCount|0]</div>');
   }
 
-  var clasterStyle = this.clustererObject.getClasterStyle(this);
+  var clusterStyle = this.clustererObject.getClusterStyle(this);
   var style = new YMaps.Style();
   style.iconStyle = new YMaps.IconStyle(template);
-  style.iconStyle.href = clasterStyle.icon;
-  style.iconStyle.size = new YMaps.Point(clasterStyle.width, clasterStyle.height);
-  style.iconStyle.offset = new YMaps.Point(clasterStyle.offset[0], clasterStyle.offset[1]);
+  style.iconStyle.href = clusterStyle.icon;
+  style.iconStyle.size = new YMaps.Point(clusterStyle.width, clusterStyle.height);
+  style.iconStyle.offset = new YMaps.Point(clusterStyle.offset[0], clusterStyle.offset[1]);
   this.point = new YMaps.Placemark(position, {
     style: style,
     hasBalloon: false
   });
   this.point.markersCount = this.markers.length;
-  this.point.textSize = clasterStyle.textSize;
-  this.point.textColor = clasterStyle.textColor;
+  this.point.textSize = clusterStyle.textSize;
+  this.point.textColor = clusterStyle.textColor;
 
   // click event - zoom to cluster bounds
   YMaps.Events.observe(this.point, this.point.Events.Click, function () {
-    this.map.setBounds(this.getClasterBounds());
+    this.map.setBounds(this.getClusterBounds());
     // Don't zoom beyond the max zoom level
     if (this.clustererObject.getMaxZoom() < this.map.getZoom()) {
       this.map.setZoom(this.clustererObject.getMaxZoom() + 1);
 };
 
 /**
- * The function that calculates style index for claster.
+ * The function that calculates style index for cluster.
  * @param {number} styles_num styles count
  * @return {number} style index
  */
     index++;
   }
 
-  index = Math.min(index, styles_num);
+  index = Math.min(index, styles_num-1);
   return index;
 };

yandex.clusterer.min.js

 /**
  * @name YandexClusterer for Yandex Maps.
- * @version 1.0.0 [August 13, 2011]
+ * @version 1.1.0 [March 02, 2012]
  * @author Alexander Shabunevich [http://aether.ru]
  * http://beholder.bitbucket.org/yandex.clusterer/
  *
  * Based on MarkerClustererPlus for Google Maps V3 by Gary Little
  */
-function YandexClusterer(map,markers,opts){this.map=map;this.bounds=null;this.clusters=[];this.markers=markers||[];this.zoom=null;this.map.YandexClusterer=this;this.yandexObjectManager=new YMaps.ObjectManager();this.map.addOverlay(this.yandexObjectManager);opts=opts||{};this.max_zoom=opts.max_zoom||0;this.grid=opts.grid||60;this.min_size=opts.min_size||2;this.centered=opts.centered||false;this.batch=opts.batch||400;this.imagePath_=opts.imagePath||YandexClusterer.IMAGE_PATH;this.imageExtension_=opts.imageExtension||YandexClusterer.IMAGE_EXTENSION;this.imageSizes_=opts.imageSizes||YandexClusterer.IMAGE_SIZES;this.styles=opts.styles||this.generateClasterStyles();this.printable=opts.printable||false;if(this.map._yandexClustererEvents){for(event in this.map._yandexClustererEvents){this.map._yandexClustererEvents[event].cleanup()}}this.map._yandexClustererEvents={};this.map._yandexClustererEvents['update']=YMaps.Events.observe(this.map,this.map.Events.Update,function(){this.repaint()},this);this.map._yandexClustererEvents['move']=YMaps.Events.observe(this.map,this.map.Events.MoveEnd,function(){this.redraw()},this);this.repaint()}YandexClusterer.prototype.setMarkers=function(markers){this.markers=markers};YandexClusterer.prototype.clearMarkers=function(){var l=this.markers.length;while(l--){var marker=this.markers[l];this.map.removeOverlay(marker);marker.isAdded=false;if(marker.isOnMap){marker.isOnMap=false}}this.yandexObjectManager.removeAll();l=this.clusters.length;while(l--){this.clusters[l].remove()}this.clusters=[]};YandexClusterer.prototype.repaint=function(){this.clearMarkers();this.redraw()};YandexClusterer.prototype.redraw=function(){this.createClusters(0)};YandexClusterer.prototype.createClusters=function(iter){var self=this;var i=iter;var length=this.markers.length;var iter_last=Math.min(iter+this.batch,length);if(iter===0){this.bounds=this.extendBounds(this.map.getBounds());this.zoom=this.map.getZoom();if(typeof this.timerRefStatic!=="undefined"){clearTimeout(this.timerRefStatic);delete this.timerRefStatic}}for(;i<iter_last;i++){var marker=this.markers[i];if(!marker.isAdded&&this.bounds.contains(marker.getCoordPoint())){this.addToCluster(marker)}}if(iter_last<length){this.timerRefStatic=setTimeout(function(){self.createClusters(iter_last)},0)}else{delete this.timerRefStatic;setTimeout(function(){self.updateClusterIcons()},0)}};YandexClusterer.prototype.extendBounds=function(bounds){var converter=this.map.converter,rtPix,lbPix,ne,sw;rtPix=converter.coordinatesToMapPixels(bounds.getRightTop());rtPix.x+=this.grid;rtPix.y-=this.grid;lbPix=converter.coordinatesToMapPixels(bounds.getLeftBottom());lbPix.x-=this.grid;lbPix.y+=this.grid;ne=converter.mapPixelsToCoordinates(rtPix);sw=converter.mapPixelsToCoordinates(lbPix);return new YMaps.GeoBounds(sw,ne)};YandexClusterer.prototype.addToCluster=function(marker){var d,cluster,center,l=this.clusters.length;var distance=40000;var clusterToAddTo=null;while(l--){cluster=this.clusters[l];if(cluster.center){d=this.distanceBetween(cluster.center,marker.getCoordPoint());if(d<distance){distance=d;clusterToAddTo=cluster}}}if(clusterToAddTo&&clusterToAddTo.isMarkerInBounds(marker)){clusterToAddTo.addMarker(marker)}else{cluster=new YandexCluster(this);cluster.addMarker(marker);this.clusters.push(cluster)}};YandexClusterer.prototype.distanceBetween=function(p1,p2){return p1.distance(p2)/1000};YandexClusterer.prototype.updateClusterIcons=function(){var self=this;var l=this.clusters.length;var max_zoom=this.getMaxZoom();var max_map_zoom=this.map.getZoom();while(l--){var cluster=this.clusters[l];count=cluster.markers.length;if(max_map_zoom>=max_zoom){var i=cluster.markers.length;while(i--){var marker=cluster.markers[i];if(!marker.isOnMap){this.yandexObjectManager.add(marker,this.zoom,this.zoom);marker.isOnMap=true}}continue}else if(count<this.min_size){var i=cluster.markers.length;while(i--){var marker=cluster.markers[i];if(!marker.isOnMap){this.yandexObjectManager.add(marker,this.zoom,this.zoom);marker.isOnMap=true}}continue}else{var i=cluster.markers.length;while(i--){var marker=cluster.markers[i];this.map.removeOverlay(marker);marker.isOnMap=false}}cluster.showIcon()}};YandexClusterer.prototype.getMaxZoom=function(){return this.max_zoom||this.map.getMaxZoom()};YandexClusterer.prototype.getClasterStyle=function(cluster){return this.styles[cluster.getIconStyleIndex(this.getStylesCount())]};YandexClusterer.prototype.generateClasterStyles=function(){var styles=[];for(var i=0;i<this.getStylesCount();i++){styles.push(this.genStyleForIndex(i))}return styles};YandexClusterer.prototype.genStyleForIndex=function(index){var size=this.imageSizes_[index];var iconPath=this.imagePath_+(index+1)+this.imageExtension_;var style={icon:iconPath,height:size,width:size,offset:[-parseInt(size/2,10),-parseInt(size/2,10)],textColor:'#000000',textSize:11};return style};YandexClusterer.prototype.getStylesCount=function(){return this.imageSizes_.length};YandexClusterer.IMAGE_PATH="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m";YandexClusterer.IMAGE_EXTENSION=".png";YandexClusterer.IMAGE_SIZES=[53,56,66,78,90];function YandexCluster(clasterOwner){this.clustererObject=clasterOwner;this.yandexObjectManager=clasterOwner.yandexObjectManager;this.map=clasterOwner.map;this.center=null;this.markers=[];this.markers_bounds=new YMaps.GeoCollectionBounds();this.bounds=null;this.min_size=clasterOwner.min_size;this.point=null}YandexCluster.prototype.addMarker=function(marker){var count,i,zoom=this.map.getZoom();if(marker.isAdded)return false;if(!this.center){this.center=marker.getCoordPoint();this.bounds=this.calculateBounds()}else if(this.clustererObject.centered){var l=this.markers.length+1,m_coord=marker.getCoordPoint();var lat=(this.center.getLat()*(l-1)+m_coord.getLat())/l;var lng=(this.center.getLng()*(l-1)+m_coord.getLng())/l;this.center=new YMaps.GeoPoint(lng,lat);this.bounds=this.calculateBounds()}marker.isAdded=true;this.markers.push(marker);this.markers_bounds.add(marker.getGeoPoint());return true};YandexCluster.prototype.getClasterBounds=function(){return this.markers_bounds};YandexCluster.prototype.calculateBounds=function(){var bounds=new YMaps.GeoCollectionBounds(this.center);return this.clustererObject.extendBounds(bounds)};YandexCluster.prototype.isMarkerInBounds=function(marker){return this.bounds.contains(marker.getCoordPoint())};YandexCluster.prototype.showIcon=function(){var self=this,position=new YMaps.GeoPoint(this.center.getLng(),this.center.getLat());if(this.point){this.yandexObjectManager.remove(this.point)}if(this.clustererObject.printable){var template=new YMaps.Template('<div style="cursor:pointer;position:relative;line-height:$[style.iconStyle.size.y]px;height:$[style.iconStyle.size.y]px;width:$[style.iconStyle.size.x]px;text-align:center"><img src="$[style.iconStyle.href]" alt="" style="position:absolute;left:0;top:0"><span style="position:relative;font-weight:bold;font-size:$[textSize|12]px;color:$[textColor|#000]">$[markersCount|0]</span></div>')}else{var template=new YMaps.Template('<div style="cursor:pointer;position:relative;line-height:$[style.iconStyle.size.y]px;height:$[style.iconStyle.size.y]px;width:$[style.iconStyle.size.x]px;text-align:center;background:url($[style.iconStyle.href]) no-repeat;font-weight:bold;font-size:$[textSize|12]px;color:$[textColor|#000]">$[markersCount|0]</div>')}var clasterStyle=this.clustererObject.getClasterStyle(this);var style=new YMaps.Style();style.iconStyle=new YMaps.IconStyle(template);style.iconStyle.href=clasterStyle.icon;style.iconStyle.size=new YMaps.Point(clasterStyle.width,clasterStyle.height);style.iconStyle.offset=new YMaps.Point(clasterStyle.offset[0],clasterStyle.offset[1]);this.point=new YMaps.Placemark(position,{style:style,hasBalloon:false});this.point.markersCount=this.markers.length;this.point.textSize=clasterStyle.textSize;this.point.textColor=clasterStyle.textColor;YMaps.Events.observe(this.point,this.point.Events.Click,function(){this.map.setBounds(this.getClasterBounds());if(this.clustererObject.getMaxZoom()<this.map.getZoom()){this.map.setZoom(this.clustererObject.getMaxZoom()+1)}},this);var zoom=this.map.getZoom();this.yandexObjectManager.add(this.point,zoom,zoom)};YandexCluster.prototype.remove=function(){this.markers=[];this.markers_bounds.clear();if(this.point){this.point=null}};YandexCluster.prototype.getIconStyleIndex=function(styles_num){var index=-1;var count=this.markers.length.toString();var dv=count;while(dv!==0){dv=parseInt(dv/10,10);index++}index=Math.min(index,styles_num);return index};
+function YandexClusterer(map,markers,opts){this.map=map;this.bounds=null;this.clusters=[];this.markers=markers||[];this.zoom=null;this.map.YandexClusterer=this;this.yandexObjectManager=new YMaps.ObjectManager();this.map.addOverlay(this.yandexObjectManager);opts=opts||{};this.max_zoom=opts.max_zoom||0;this.grid=opts.grid||60;this.min_size=opts.min_size||2;this.centered=opts.centered||false;this.batch=opts.batch||400;this.imagePath_=opts.imagePath||YandexClusterer.IMAGE_PATH;this.imageExtension_=opts.imageExtension||YandexClusterer.IMAGE_EXTENSION;this.imageSizes_=opts.imageSizes||YandexClusterer.IMAGE_SIZES;this.styles=opts.styles||this.generateClusterStyles();this.printable=opts.printable||false;if(this.map._yandexClustererEvents){for(event in this.map._yandexClustererEvents){this.map._yandexClustererEvents[event].cleanup()}}this.map._yandexClustererEvents={};this.map._yandexClustererEvents['update']=YMaps.Events.observe(this.map,this.map.Events.Update,function(){this.repaint()},this);this.map._yandexClustererEvents['move']=YMaps.Events.observe(this.map,this.map.Events.MoveEnd,function(){this.redraw()},this);this.repaint()}YandexClusterer.prototype.setMarkers=function(markers){this.markers=markers}YandexClusterer.prototype.clearMarkers=function(){var l=this.markers.length;while(l--){var marker=this.markers[l];this.map.removeOverlay(marker);marker.isAdded=false;if(marker.isOnMap){marker.isOnMap=false}}this.yandexObjectManager.removeAll();l=this.clusters.length;while(l--){this.clusters[l].remove()}this.clusters=[]}YandexClusterer.prototype.repaint=function(){this.clearMarkers();this.redraw()}YandexClusterer.prototype.redraw=function(){this.createClusters(0)}YandexClusterer.prototype.createClusters=function(iter){var self=this;var i=iter;var length=this.markers.length;var iter_last=Math.min(iter+this.batch,length);if(iter===0){this.bounds=this.extendBounds(this.map.getBounds());this.zoom=this.map.getZoom();if(typeof this.timerRefStatic!=="undefined"){clearTimeout(this.timerRefStatic);delete this.timerRefStatic}}for(;i<iter_last;i++){var marker=this.markers[i];if(!marker.isAdded&&this.bounds.contains(marker.getCoordPoint())){this.addToCluster(marker)}}if(iter_last<length){this.timerRefStatic=setTimeout(function(){self.createClusters(iter_last)},0)}else{delete this.timerRefStatic;setTimeout(function(){self.updateClusterIcons()},0)}}YandexClusterer.prototype.extendBounds=function(bounds){var converter=this.map.converter,rtPix,lbPix,ne,sw;rtPix=converter.coordinatesToMapPixels(bounds.getRightTop());rtPix.x+=this.grid;rtPix.y-=this.grid;lbPix=converter.coordinatesToMapPixels(bounds.getLeftBottom());lbPix.x-=this.grid;lbPix.y+=this.grid;ne=converter.mapPixelsToCoordinates(rtPix);sw=converter.mapPixelsToCoordinates(lbPix);return new YMaps.GeoBounds(sw,ne)}YandexClusterer.prototype.addToCluster=function(marker){var d,cluster,center,l=this.clusters.length;var distance=40000;var clusterToAddTo=null;while(l--){cluster=this.clusters[l];if(cluster.center){d=this.distanceBetween(cluster.center,marker.getCoordPoint());if(d<distance){distance=d;clusterToAddTo=cluster}}}if(clusterToAddTo&&clusterToAddTo.isMarkerInBounds(marker)){clusterToAddTo.addMarker(marker)}else{cluster=new YandexCluster(this);cluster.addMarker(marker);this.clusters.push(cluster)}}YandexClusterer.prototype.distanceBetween=function(p1,p2){return p1.distance(p2)/1000};YandexClusterer.prototype.updateClusterIcons=function(){var self=this,l=this.clusters.length,max_zoom=this.getMaxZoom(),max_map_zoom=this.map.getZoom();while(l--){var cluster=this.clusters[l];count=cluster.markers.length;if(max_map_zoom>=max_zoom){var i=cluster.markers.length;while(i--){var marker=cluster.markers[i];if(!marker.isOnMap){this.yandexObjectManager.add(marker,this.zoom,this.zoom);marker.isOnMap=true}}continue}else if(count<this.min_size){var i=cluster.markers.length;while(i--){var marker=cluster.markers[i];if(!marker.isOnMap){this.yandexObjectManager.add(marker,this.zoom,this.zoom);marker.isOnMap=true}}continue}else{var i=cluster.markers.length;while(i--){var marker=cluster.markers[i];this.map.removeOverlay(marker);marker.isOnMap=false}}cluster.showIcon()}}YandexClusterer.prototype.getMaxZoom=function(){return this.max_zoom||this.map.getMaxZoom()};YandexClusterer.prototype.getClusterStyle=function(cluster){return this.styles[cluster.getIconStyleIndex(this.getStylesCount())]};YandexClusterer.prototype.generateClusterStyles=function(){var styles=[];for(var i=0;i<this.getStylesCount();i++){styles.push(this.genStyleForIndex(i))}return styles};YandexClusterer.prototype.genStyleForIndex=function(index){var size=this.imageSizes_[index];var iconPath=this.imagePath_+(index+1)+this.imageExtension_;var style={icon:iconPath,height:size,width:size,offset:[-parseInt(size/2,10),-parseInt(size/2,10)],textColor:'#000000',textSize:11};return style};YandexClusterer.prototype.getStylesCount=function(){return this.imageSizes_.length}YandexClusterer.IMAGE_PATH="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m";YandexClusterer.IMAGE_EXTENSION=".png";YandexClusterer.IMAGE_SIZES=[53,56,66,78,90];function YandexCluster(clusterOwner){this.clustererObject=clusterOwner;this.yandexObjectManager=clusterOwner.yandexObjectManager;this.map=clusterOwner.map;this.center=null;this.markers=[];this.markers_bounds=new YMaps.GeoCollectionBounds();this.bounds=null;this.min_size=clusterOwner.min_size;this.point=null}YandexCluster.prototype.addMarker=function(marker){var count,i,zoom=this.map.getZoom();if(marker.isAdded)return false;if(!this.center){this.center=marker.getCoordPoint();this.bounds=this.calculateBounds()}else if(this.clustererObject.centered){var l=this.markers.length+1,m_coord=marker.getCoordPoint();var lat=(this.center.getLat()*(l-1)+m_coord.getLat())/l;var lng=(this.center.getLng()*(l-1)+m_coord.getLng())/l;this.center=new YMaps.GeoPoint(lng,lat);this.bounds=this.calculateBounds()}marker.isAdded=true;this.markers.push(marker);this.markers_bounds.add(marker.getGeoPoint());return true}YandexCluster.prototype.getClusterBounds=function(){return this.markers_bounds};YandexCluster.prototype.calculateBounds=function(){var bounds=new YMaps.GeoCollectionBounds(this.center);return this.clustererObject.extendBounds(bounds)};YandexCluster.prototype.isMarkerInBounds=function(marker){return this.bounds.contains(marker.getCoordPoint())}YandexCluster.prototype.showIcon=function(){var self=this,position=new YMaps.GeoPoint(this.center.getLng(),this.center.getLat());if(this.point){this.yandexObjectManager.remove(this.point)}if(this.clustererObject.printable){var template=new YMaps.Template('<div style="cursor:pointer;position:relative;line-height:$[style.iconStyle.size.y]px;height:$[style.iconStyle.size.y]px;width:$[style.iconStyle.size.x]px;text-align:center"><img src="$[style.iconStyle.href]" alt="" style="position:absolute;left:0;top:0"><span style="position:relative;font-weight:bold;font-size:$[textSize|12]px;color:$[textColor|#000]">$[markersCount|0]</span></div>')}else{var template=new YMaps.Template('<div style="cursor:pointer;position:relative;line-height:$[style.iconStyle.size.y]px;height:$[style.iconStyle.size.y]px;width:$[style.iconStyle.size.x]px;text-align:center;background:url($[style.iconStyle.href]) no-repeat;font-weight:bold;font-size:$[textSize|12]px;color:$[textColor|#000]">$[markersCount|0]</div>')}var clusterStyle=this.clustererObject.getClusterStyle(this);var style=new YMaps.Style();style.iconStyle=new YMaps.IconStyle(template);style.iconStyle.href=clusterStyle.icon;style.iconStyle.size=new YMaps.Point(clusterStyle.width,clusterStyle.height);style.iconStyle.offset=new YMaps.Point(clusterStyle.offset[0],clusterStyle.offset[1]);this.point=new YMaps.Placemark(position,{style:style,hasBalloon:false});this.point.markersCount=this.markers.length;this.point.textSize=clusterStyle.textSize;this.point.textColor=clusterStyle.textColor;YMaps.Events.observe(this.point,this.point.Events.Click,function(){this.map.setBounds(this.getClusterBounds());if(this.clustererObject.getMaxZoom()<this.map.getZoom()){this.map.setZoom(this.clustererObject.getMaxZoom()+1)}},this);var zoom=this.map.getZoom();this.yandexObjectManager.add(this.point,zoom,zoom)}YandexCluster.prototype.remove=function(){this.markers=[];this.markers_bounds.clear();if(this.point){this.point=null}};YandexCluster.prototype.getIconStyleIndex=function(styles_num){var index=-1;var count=this.markers.length.toString();var dv=count;while(dv!==0){dv=parseInt(dv/10,10);index++}index=Math.min(index,styles_num-1);return index};

yandex.clusterer.packed.js

-eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('5 7(a,b,c){3.6=a;3.B=D;3.t=[];3.f=b||[];3.C=D;3.6.7=3;3.s=j g.2t();3.6.2B(3.s);c=c||{};3.18=c.18||0;3.K=c.K||2E;3.U=c.U||2;3.16=c.16||A;3.1b=c.1b||2P;3.2a=c.2w||7.25;3.23=c.2F||7.20;3.1u=c.2p||7.1Z;3.17=c.17||3.1Y();3.19=c.19||A;9(3.6.L){1f(1W 2q 3.6.L){3.6.L[1W].2r()}}3.6.L={};3.6.L[\'2s\']=g.G.1k(3.6,3.6.G.2z,5(){3.1m()},3);3.6.L[\'2C\']=g.G.1k(3.6,3.6.G.2D,5(){3.1q()},3);3.1m()}7.8.2H=5(a){3.f=a};7.8.1T=5(){4 l=3.f.o;v(l--){4 a=3.f[l];3.6.1S(a);a.15=A;9(a.F){a.F=A}}3.s.2x();l=3.t.o;v(l--){3.t[l].1d()}3.t=[]};7.8.1m=5(){3.1T();3.1q()};7.8.1q=5(){3.1e(0)};7.8.1e=5(a){4 b=3;4 i=a;4 c=3.f.o;4 d=1Q.1N(a+3.1b,c);9(a===0){3.B=3.1j(3.6.2I());3.C=3.6.R();9(2L 3.N!=="2U"){2W(3.N);1M 3.N}}1f(;i<d;i++){4 e=3.f[i];9(!e.15&&3.B.1L(e.O())){3.1K(e)}}9(d<c){3.N=1J(5(){b.1e(d)},0)}J{1M 3.N;1J(5(){b.1H()},0)}};7.8.1j=5(a){4 b=3.6.2A,S,P,1h,1a;S=b.1G(a.2G());S.x+=3.K;S.y-=3.K;P=b.1G(a.2J());P.x-=3.K;P.y+=3.K;1h=b.1F(S);1a=b.1F(P);k j g.2M(1a,1h)};7.8.1K=5(a){4 d,z,h,l=3.t.o;4 b=3e;4 c=D;v(l--){z=3.t[l];9(z.h){d=3.1E(z.h,a.O());9(d<b){b=d;c=z}}}9(c&&c.1D(a)){c.1l(a)}J{z=j r(3);z.1l(a);3.t.1n(z)}};7.8.1E=5(a,b){k a.2u(b)/2v};7.8.1H=5(){4 a=3;4 l=3.t.o;4 b=3.T();4 c=3.6.R();v(l--){4 d=3.t[l];1C=d.f.o;9(c>=b){4 i=d.f.o;v(i--){4 e=d.f[i];9(!e.F){3.s.Y(e,3.C,3.C);e.F=Z}}1B}J 9(1C<3.U){4 i=d.f.o;v(i--){4 e=d.f[i];9(!e.F){3.s.Y(e,3.C,3.C);e.F=Z}}1B}J{4 i=d.f.o;v(i--){4 e=d.f[i];3.6.1S(e);e.F=A}}d.1A()}};7.8.T=5(){k 3.18||3.6.T()};7.8.1z=5(a){k 3.17[a.1R(3.1v())]};7.8.1Y=5(){4 a=[];1f(4 i=0;i<3.1v();i++){a.1n(3.1x(i))}k a};7.8.1x=5(a){4 b=3.1u[a];4 c=3.2a+(a+1)+3.23;4 d={1y:c,H:b,14:b,13:[-1p(b/2,10),-1p(b/2,10)],M:\'#2V\',Q:11};k d};7.8.1v=5(){k 3.1u.o};7.25="2X://2Y-2Z-30-37-2c.2d.2e/2f/2g/2h/2i/m";7.20=".2j";7.1Z=[2k,2l,2m,2n,2o];5 r(a){3.E=a;3.s=a.s;3.6=a.6;3.h=D;3.f=[];3.W=j g.1I();3.B=D;3.U=a.U;3.p=D}r.8.1l=5(a){4 b,i,C=3.6.R();9(a.15)k A;9(!3.h){3.h=a.O();3.B=3.1t()}J 9(3.E.16){4 l=3.f.o+1,1r=a.O();4 c=(3.h.1o()*(l-1)+1r.1o())/l;4 d=(3.h.1i()*(l-1)+1r.1i())/l;3.h=j g.1O(d,c);3.B=3.1t()}a.15=Z;3.f.1n(a);3.W.Y(a.2y());k Z};r.8.1P=5(){k 3.W};r.8.1t=5(){4 a=j g.1I(3.h);k 3.E.1j(a)};r.8.1D=5(a){k 3.B.1L(a.O())};r.8.1A=5(){4 a=3,I=j g.1O(3.h.1i(),3.h.1o());9(3.p){3.s.1d(3.p)}9(3.E.19){4 b=j g.1w(\'<V n="1U:1V;I:1g;1X-H:$[n.q.u.y]w;H:$[n.q.u.y]w;14:$[n.q.u.x]w;21-22:h"><2N 2O="$[n.q.1s]" 2Q="" n="I:2R;2S:0;2T:0"><24 n="I:1g;X-26:27;X-u:$[Q|12]w;28:$[M|#29]">$[1c|0]</24></V>\')}J{4 b=j g.1w(\'<V n="1U:1V;I:1g;1X-H:$[n.q.u.y]w;H:$[n.q.u.y]w;14:$[n.q.u.x]w;21-22:h;31:32($[n.q.1s]) 33-34;X-26:27;X-u:$[Q|12]w;28:$[M|#29]">$[1c|0]</V>\')}4 c=3.E.1z(3);4 d=j g.35();d.q=j g.36(b);d.q.1s=c.1y;d.q.u=j g.2b(c.14,c.H);d.q.13=j g.2b(c.13[0],c.13[1]);3.p=j g.38(I,{n:d,39:A});3.p.1c=3.f.o;3.p.Q=c.Q;3.p.M=c.M;g.G.1k(3.p,3.p.G.3a,5(){3.6.3b(3.1P());9(3.E.T()<3.6.R()){3.6.3c(3.E.T()+1)}},3);4 e=3.6.R();3.s.Y(3.p,e,e)};r.8.1d=5(){3.f=[];3.W.3d();9(3.p){3.p=D}};r.8.1R=5(a){4 b=-1;4 c=3.f.o.2K();4 d=c;v(d!==0){d=1p(d/10,10);b++}b=1Q.1N(b,a);k b};',62,201,'|||this|var|function|map|YandexClusterer|prototype|if||||||markers|YMaps|center||new|return|||style|length|point|iconStyle|YandexCluster|yandexObjectManager|clusters|size|while|px|||cluster|false|bounds|zoom|null|clustererObject|isOnMap|Events|height|position|else|grid|_yandexClustererEvents|textColor|timerRefStatic|getCoordPoint|lbPix|textSize|getZoom|rtPix|getMaxZoom|min_size|div|markers_bounds|font|add|true||||offset|width|isAdded|centered|styles|max_zoom|printable|sw|batch|markersCount|remove|createClusters|for|relative|ne|getLng|extendBounds|observe|addMarker|repaint|push|getLat|parseInt|redraw|m_coord|href|calculateBounds|imageSizes_|getStylesCount|Template|genStyleForIndex|icon|getClasterStyle|showIcon|continue|count|isMarkerInBounds|distanceBetween|mapPixelsToCoordinates|coordinatesToMapPixels|updateClusterIcons|GeoCollectionBounds|setTimeout|addToCluster|contains|delete|min|GeoPoint|getClasterBounds|Math|getIconStyleIndex|removeOverlay|clearMarkers|cursor|pointer|event|line|generateClasterStyles|IMAGE_SIZES|IMAGE_EXTENSION|text|align|imageExtension_|span|IMAGE_PATH|weight|bold|color|000|imagePath_|Point|v3|googlecode|com|svn|trunk|markerclustererplus|images|png|53|56|66|78|90|imageSizes|in|cleanup|update|ObjectManager|distance|1000|imagePath|removeAll|getGeoPoint|Update|converter|addOverlay|move|MoveEnd|60|imageExtension|getRightTop|setMarkers|getBounds|getLeftBottom|toString|typeof|GeoBounds|img|src|400|alt|absolute|left|top|undefined|000000|clearTimeout|http|google|maps|utility|background|url|no|repeat|Style|IconStyle|library|Placemark|hasBalloon|Click|setBounds|setZoom|clear|40000'.split('|'),0,{}))
+eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('5 7(a,b,c){3.6=a;3.A=B;3.r=[];3.f=b||[];3.C=B;3.6.7=3;3.s=h g.2d();3.6.2e(3.s);c=c||{};3.M=c.M||0;3.G=c.G||2f;3.N=c.N||2;3.17=c.17||D;3.18=c.18||2g;3.1w=c.2h||7.1x;3.1y=c.2i||7.1z;3.19=c.2j||7.1A;3.1a=c.1a||3.1B();3.1b=c.1b||D;9(3.6.H){1c(1C 2k 3.6.H){3.6.H[1C].2l()}}3.6.H={};3.6.H[\'2m\']=g.I.1d(3.6,3.6.I.2n,5(){3.1e()},3);3.6.H[\'2o\']=g.I.1d(3.6,3.6.I.2p,5(){3.1f()},3);3.1e()}7.8.2q=5(a){3.f=a}7.8.1D=5(){4 l=3.f.k;v(l--){4 a=3.f[l];3.6.1E(a);a.W=D;9(a.E){a.E=D}}3.s.2r();l=3.r.k;v(l--){3.r[l].1g()}3.r=[]}7.8.1e=5(){3.1D();3.1f()}7.8.1f=5(){3.1h(0)}7.8.1h=5(a){4 b=3;4 i=a;4 c=3.f.k;4 d=1F.1G(a+3.18,c);9(a===0){3.A=3.1i(3.6.2s());3.C=3.6.O();9(2t 3.P!=="2u"){2v(3.P);1H 3.P}}1c(;i<d;i++){4 e=3.f[i];9(!e.W&&3.A.1I(e.Q())){3.1J(e)}}9(d<c){3.P=1K(5(){b.1h(d)},0)}J{1H 3.P;1K(5(){b.1L()},0)}}7.8.1i=5(a){4 b=3.6.2w,R,S,1j,1k;R=b.1M(a.2x());R.x+=3.G;R.y-=3.G;S=b.1M(a.2y());S.x-=3.G;S.y+=3.G;1j=b.1N(R);1k=b.1N(S);n h g.2z(1k,1j)}7.8.1J=5(a){4 d,w,j,l=3.r.k;4 b=2A;4 c=B;v(l--){w=3.r[l];9(w.j){d=3.1O(w.j,a.Q());9(d<b){b=d;c=w}}}9(c&&c.1P(a)){c.1l(a)}J{w=h t(3);w.1l(a);3.r.1m(w)}}7.8.1O=5(a,b){n a.2B(b)/2C};7.8.1L=5(){4 a=3,l=3.r.k,M=3.T(),1Q=3.6.O();v(l--){4 b=3.r[l];1R=b.f.k;9(1Q>=M){4 i=b.f.k;v(i--){4 c=b.f[i];9(!c.E){3.s.X(c,3.C,3.C);c.E=Y}}1S}J 9(1R<3.N){4 i=b.f.k;v(i--){4 c=b.f[i];9(!c.E){3.s.X(c,3.C,3.C);c.E=Y}}1S}J{4 i=b.f.k;v(i--){4 c=b.f[i];3.6.1E(c);c.E=D}}b.1T()}}7.8.T=5(){n 3.M||3.6.T()};7.8.1U=5(a){n 3.1a[a.1V(3.1n())]};7.8.1B=5(){4 a=[];1c(4 i=0;i<3.1n();i++){a.1m(3.1W(i))}n a};7.8.1W=5(a){4 b=3.19[a];4 c=3.1w+(a+1)+3.1y;4 d={1X:c,K:b,Z:b,13:[-1o(b/2,10),-1o(b/2,10)],U:\'#2D\',V:11};n d};7.8.1n=5(){n 3.19.k}7.1x="2E://2F-2G-2H-2I-2J.2K.2L/2M/2N/2O/2P/m";7.1z=".2Q";7.1A=[2R,2S,2T,2U,2V];5 t(a){3.F=a;3.s=a.s;3.6=a.6;3.j=B;3.f=[];3.14=h g.1Y();3.A=B;3.N=a.N;3.p=B}t.8.1l=5(a){4 b,i,C=3.6.O();9(a.W)n D;9(!3.j){3.j=a.Q();3.A=3.1p()}J 9(3.F.17){4 l=3.f.k+1,1q=a.Q();4 c=(3.j.1r()*(l-1)+1q.1r())/l;4 d=(3.j.1s()*(l-1)+1q.1s())/l;3.j=h g.1Z(d,c);3.A=3.1p()}a.W=Y;3.f.1m(a);3.14.X(a.2W());n Y}t.8.20=5(){n 3.14};t.8.1p=5(){4 a=h g.1Y(3.j);n 3.F.1i(a)};t.8.1P=5(a){n 3.A.1I(a.Q())}t.8.1T=5(){4 a=3,L=h g.1Z(3.j.1s(),3.j.1r());9(3.p){3.s.1g(3.p)}9(3.F.1b){4 b=h g.21(\'<15 o="22:23;L:1t;24-K:$[o.q.u.y]z;K:$[o.q.u.y]z;Z:$[o.q.u.x]z;25-26:j"><2X 2Y="$[o.q.1u]" 2Z="" o="L:30;31:0;32:0"><27 o="L:1t;16-28:29;16-u:$[V|12]z;2a:$[U|#2b]">$[1v|0]</27></15>\')}J{4 b=h g.21(\'<15 o="22:23;L:1t;24-K:$[o.q.u.y]z;K:$[o.q.u.y]z;Z:$[o.q.u.x]z;25-26:j;33:34($[o.q.1u]) 35-36;16-28:29;16-u:$[V|12]z;2a:$[U|#2b]">$[1v|0]</15>\')}4 c=3.F.1U(3);4 d=h g.37();d.q=h g.38(b);d.q.1u=c.1X;d.q.u=h g.2c(c.Z,c.K);d.q.13=h g.2c(c.13[0],c.13[1]);3.p=h g.39(L,{o:d,3a:D});3.p.1v=3.f.k;3.p.V=c.V;3.p.U=c.U;g.I.1d(3.p,3.p.I.3b,5(){3.6.3c(3.20());9(3.F.T()<3.6.O()){3.6.3d(3.F.T()+1)}},3);4 e=3.6.O();3.s.X(3.p,e,e)}t.8.1g=5(){3.f=[];3.14.3e();9(3.p){3.p=B}};t.8.1V=5(a){4 b=-1;4 c=3.f.k.3f();4 d=c;v(d!==0){d=1o(d/10,10);b++}b=1F.1G(b,a-1);n b};',62,202,'|||this|var|function|map|YandexClusterer|prototype|if||||||markers|YMaps|new||center|length|||return|style|point|iconStyle|clusters|yandexObjectManager|YandexCluster|size|while|cluster|||px|bounds|null|zoom|false|isOnMap|clustererObject|grid|_yandexClustererEvents|Events|else|height|position|max_zoom|min_size|getZoom|timerRefStatic|getCoordPoint|rtPix|lbPix|getMaxZoom|textColor|textSize|isAdded|add|true|width||||offset|markers_bounds|div|font|centered|batch|imageSizes_|styles|printable|for|observe|repaint|redraw|remove|createClusters|extendBounds|ne|sw|addMarker|push|getStylesCount|parseInt|calculateBounds|m_coord|getLat|getLng|relative|href|markersCount|imagePath_|IMAGE_PATH|imageExtension_|IMAGE_EXTENSION|IMAGE_SIZES|generateClusterStyles|event|clearMarkers|removeOverlay|Math|min|delete|contains|addToCluster|setTimeout|updateClusterIcons|coordinatesToMapPixels|mapPixelsToCoordinates|distanceBetween|isMarkerInBounds|max_map_zoom|count|continue|showIcon|getClusterStyle|getIconStyleIndex|genStyleForIndex|icon|GeoCollectionBounds|GeoPoint|getClusterBounds|Template|cursor|pointer|line|text|align|span|weight|bold|color|000|Point|ObjectManager|addOverlay|60|400|imagePath|imageExtension|imageSizes|in|cleanup|update|Update|move|MoveEnd|setMarkers|removeAll|getBounds|typeof|undefined|clearTimeout|converter|getRightTop|getLeftBottom|GeoBounds|40000|distance|1000|000000|http|google|maps|utility|library|v3|googlecode|com|svn|trunk|markerclustererplus|images|png|53|56|66|78|90|getGeoPoint|img|src|alt|absolute|left|top|background|url|no|repeat|Style|IconStyle|Placemark|hasBalloon|Click|setBounds|setZoom|clear|toString'.split('|'),0,{}))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.