diff --git a/dist/maptalks.markercluster.js b/dist/maptalks.markercluster.js index 75000e2..0d249b7 100644 --- a/dist/maptalks.markercluster.js +++ b/dist/maptalks.markercluster.js @@ -1,5 +1,5 @@ /*! - * maptalks.markercluster v0.3.0 + * maptalks.markercluster v0.4.0 * LICENSE : MIT * (c) 2016-2017 maptalks.org */ @@ -225,11 +225,11 @@ ClusterLayer.registerRenderer('canvas', function (_maptalks$renderer$Ve) { } }; - _class.prototype.drawOnZooming = function drawOnZooming() { + _class.prototype.drawOnInteracting = function drawOnInteracting() { if (this._currentClusters) { this._drawClusters(this._currentClusters, 1); } - _maptalks$renderer$Ve.prototype.drawOnZooming.apply(this, arguments); + _maptalks$renderer$Ve.prototype.drawOnInteracting.apply(this, arguments); }; _class.prototype.onGeometryAdd = function onGeometryAdd() { @@ -289,10 +289,6 @@ ClusterLayer.registerRenderer('canvas', function (_maptalks$renderer$Ve) { this.draw(); }; - _class.prototype.isRenderOnZooming = function isRenderOnZooming() { - return true; - }; - _class.prototype._refreshStyle = function _refreshStyle() { var _this3 = this; @@ -333,8 +329,7 @@ ClusterLayer.registerRenderer('canvas', function (_maptalks$renderer$Ve) { }; _class.prototype._drawMarkers = function _drawMarkers() { - _maptalks$renderer$Ve.prototype._drawGeos.call(this, this._clusterMaskExtent); - this._isBlank = false; + _maptalks$renderer$Ve.prototype.drawGeos.call(this, this._clusterMaskExtent); }; _class.prototype._drawClusters = function _drawClusters(clusters, ratio, matrix) { diff --git a/dist/maptalks.markercluster.min.js b/dist/maptalks.markercluster.min.js index 39a5953..91ecb64 100644 --- a/dist/maptalks.markercluster.min.js +++ b/dist/maptalks.markercluster.min.js @@ -1,6 +1,6 @@ /*! - * maptalks.markercluster v0.3.0 + * maptalks.markercluster v0.4.0 * LICENSE : MIT * (c) 2016-2017 maptalks.org */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks")):"function"==typeof define&&define.amd?define(["exports","maptalks"],e):e(t.maptalks=t.maptalks||{},t.maptalks)}(this,function(t,e){"use strict";function r(t,e){for(var r=Object.getOwnPropertyNames(e),o=0;oi)return delete this._currentClusters,this._markersToDraw=this.layer._geoList,void t.prototype.draw.apply(this,arguments);this._clusterNeedRedraw&&(this._clearDataCache(),this._computeGrid(),this._clusterNeedRedraw=!1);var n=this._clusterCache[o]?this._clusterCache[o].clusters:null;this._markersToDraw=[];var s=r.getContainerExtent(),a=[],u=void 0,l=void 0,p=void 0,c=void 0,h=void 0,y=void 0;for(var d in n)if(this._currentGrid=n[d],1!==n[d].count)p=this._getSprite(),c=p.canvas.width,h=p.canvas.height,u=r._prjToContainerPoint(n[d].center),l=new e.PointExtent(u.substract(c,h),u.add(c,h)),s.intersects(l)&&(y=e.StringUtil.getFont(this._textSymbol),n[d].textSize||(n[d].textSize=e.StringUtil.stringLength(n[d].count,y).toPoint()._multi(.5)),a.push(n[d]));else{var _=n[d].children[0];_._cluster=n[d],this._markersToDraw.push(_)}this._drawLayer(a)},r.prototype.forEachGeo=function(t,e){this._markersToDraw&&this._markersToDraw.forEach(function(r){e?t.call(e,r):t(r)})},r.prototype.drawOnZooming=function(){this._currentClusters&&this._drawClusters(this._currentClusters,1),t.prototype.drawOnZooming.apply(this,arguments)},r.prototype.onGeometryAdd=function(){this._clusterNeedRedraw=!0,this.render()},r.prototype.onGeometryRemove=function(){this._clusterNeedRedraw=!0,this.render()},r.prototype.onGeometryPositionChange=function(){this._clusterNeedRedraw=!0,this.render()},r.prototype.onRemove=function(){this._clearDataCache()},r.prototype.transform=function(t){return this._currentClusters&&this._drawClusters(this._currentClusters,1,t),!0},r.prototype.identify=function(t){var e=this.getMap();if(t=e.coordinateToContainerPoint(t),!this._currentClusters)return null;for(var r=this._currentGrid,o=0;o.5?1:e)})},r.prototype._drawCluster=function(t,r,o){this._currentGrid=r;var i=this.context,n=this._getSprite(),s=i.globalAlpha;if(s*o!==0){if(i.globalAlpha=s*o,n){var a=t.add(n.offset)._substract(n.canvas.width/2,n.canvas.height/2);i.drawImage(n.canvas,a.x,a.y)}this.layer.options.drawClusterText&&r.textSize&&(e.Canvas.prepareCanvasFont(i,this._textSymbol),e.Canvas.fillText(i,r.count,t.substract(r.textSize))),i.globalAlpha=s}},r.prototype._getSprite=function(){this._spriteCache||(this._spriteCache={});var t=e.Util.getSymbolStamp(this._symbol);return this._spriteCache[t]||(this._spriteCache[t]=new e.Marker([0,0],{symbol:this._symbol})._getSprite(this.resources,this.getMap().CanvasClass)),this._spriteCache[t]},r.prototype._initGridSystem=function(){var t=[],e=void 0,r=void 0;this.layer.forEach(function(o){r=o._getPrjCoordinates(),e=e?e._combine(o._getPrjExtent()):o._getPrjExtent(),t.push({x:r.x,y:r.y,id:o._getInternalId(),geometry:o})}),this._markerExtent=e,this._markerPoints=t},r.prototype._computeGrid=function(){var t=this.getMap(),e=t.getZoom();this._markerExtent||this._initGridSystem(),this._clusterCache||(this._clusterCache={});var r=t._getResolution(t.getMinZoom())>t._getResolution(t.getMaxZoom())?e-1:e+1;this._clusterCache[r]&&this._clusterCache[r].length===this.layer.getCount()&&(this._clusterCache[e]=this._clusterCache[r]),this._clusterCache[e]||(this._clusterCache[e]=this._computeZoomGrid(e))},r.prototype._computeZoomGrid=function(t){if(!this._markerExtent)return null;var r=this.getMap(),o=r._getResolution(t)*this.layer.options.maxClusterRadius,i=r._getResolution(t-1)?r._getResolution(t-1)*this.layer.options.maxClusterRadius:null,n=this._clusterCache[t-1];!n&&t-1>=r.getMinZoom()&&(this._clusterCache[t-1]=n=this._computeZoomGrid(t-1));for(var s=this._markerPoints,a={},u=this._markerExtent.getMin(),l=void 0,p=void 0,c=void 0,h=void 0,y=void 0,d=void 0,_=0,m=s.length;_e.to?"in":"out",this._stopAnim(),t.prototype.onZoomStart.call(this,e)},r.prototype.onZoomEnd=function(){this._animated=!0,this._computeGrid(),t.prototype.onZoomEnd.apply(this,arguments)},r.prototype._clearDataCache=function(){this._stopAnim(),delete this._markerExtent,delete this._markerPoints,delete this._clusterCache},r}(e.renderer.VectorLayerCanvasRenderer)),t.ClusterLayer=a,Object.defineProperty(t,"__esModule",{value:!0})}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks")):"function"==typeof define&&define.amd?define(["exports","maptalks"],e):e(t.maptalks=t.maptalks||{},t.maptalks)}(this,function(t,e){"use strict";function r(t,e){for(var r=Object.getOwnPropertyNames(e),o=0;oi)return delete this._currentClusters,this._markersToDraw=this.layer._geoList,void t.prototype.draw.apply(this,arguments);this._clusterNeedRedraw&&(this._clearDataCache(),this._computeGrid(),this._clusterNeedRedraw=!1);var n=this._clusterCache[o]?this._clusterCache[o].clusters:null;this._markersToDraw=[];var s=r.getContainerExtent(),a=[],u=void 0,c=void 0,l=void 0,p=void 0,h=void 0,y=void 0;for(var d in n)if(this._currentGrid=n[d],1!==n[d].count)l=this._getSprite(),p=l.canvas.width,h=l.canvas.height,u=r._prjToContainerPoint(n[d].center),c=new e.PointExtent(u.substract(p,h),u.add(p,h)),s.intersects(c)&&(y=e.StringUtil.getFont(this._textSymbol),n[d].textSize||(n[d].textSize=e.StringUtil.stringLength(n[d].count,y).toPoint()._multi(.5)),a.push(n[d]));else{var _=n[d].children[0];_._cluster=n[d],this._markersToDraw.push(_)}this._drawLayer(a)},r.prototype.forEachGeo=function(t,e){this._markersToDraw&&this._markersToDraw.forEach(function(r){e?t.call(e,r):t(r)})},r.prototype.drawOnInteracting=function(){this._currentClusters&&this._drawClusters(this._currentClusters,1),t.prototype.drawOnInteracting.apply(this,arguments)},r.prototype.onGeometryAdd=function(){this._clusterNeedRedraw=!0,this.render()},r.prototype.onGeometryRemove=function(){this._clusterNeedRedraw=!0,this.render()},r.prototype.onGeometryPositionChange=function(){this._clusterNeedRedraw=!0,this.render()},r.prototype.onRemove=function(){this._clearDataCache()},r.prototype.transform=function(t){return this._currentClusters&&this._drawClusters(this._currentClusters,1,t),!0},r.prototype.identify=function(t){var e=this.getMap();if(t=e.coordinateToContainerPoint(t),!this._currentClusters)return null;for(var r=this._currentGrid,o=0;o.5?1:e)})},r.prototype._drawCluster=function(t,r,o){this._currentGrid=r;var i=this.context,n=this._getSprite(),s=i.globalAlpha;if(s*o!==0){if(i.globalAlpha=s*o,n){var a=t.add(n.offset)._substract(n.canvas.width/2,n.canvas.height/2);i.drawImage(n.canvas,a.x,a.y)}this.layer.options.drawClusterText&&r.textSize&&(e.Canvas.prepareCanvasFont(i,this._textSymbol),e.Canvas.fillText(i,r.count,t.substract(r.textSize))),i.globalAlpha=s}},r.prototype._getSprite=function(){this._spriteCache||(this._spriteCache={});var t=e.Util.getSymbolStamp(this._symbol);return this._spriteCache[t]||(this._spriteCache[t]=new e.Marker([0,0],{symbol:this._symbol})._getSprite(this.resources,this.getMap().CanvasClass)),this._spriteCache[t]},r.prototype._initGridSystem=function(){var t=[],e=void 0,r=void 0;this.layer.forEach(function(o){r=o._getPrjCoordinates(),e=e?e._combine(o._getPrjExtent()):o._getPrjExtent(),t.push({x:r.x,y:r.y,id:o._getInternalId(),geometry:o})}),this._markerExtent=e,this._markerPoints=t},r.prototype._computeGrid=function(){var t=this.getMap(),e=t.getZoom();this._markerExtent||this._initGridSystem(),this._clusterCache||(this._clusterCache={});var r=t._getResolution(t.getMinZoom())>t._getResolution(t.getMaxZoom())?e-1:e+1;this._clusterCache[r]&&this._clusterCache[r].length===this.layer.getCount()&&(this._clusterCache[e]=this._clusterCache[r]),this._clusterCache[e]||(this._clusterCache[e]=this._computeZoomGrid(e))},r.prototype._computeZoomGrid=function(t){if(!this._markerExtent)return null;var r=this.getMap(),o=r._getResolution(t)*this.layer.options.maxClusterRadius,i=r._getResolution(t-1)?r._getResolution(t-1)*this.layer.options.maxClusterRadius:null,n=this._clusterCache[t-1];!n&&t-1>=r.getMinZoom()&&(this._clusterCache[t-1]=n=this._computeZoomGrid(t-1));for(var s=this._markerPoints,a={},u=this._markerExtent.getMin(),c=void 0,l=void 0,p=void 0,h=void 0,y=void 0,d=void 0,_=0,m=s.length;_e.to?"in":"out",this._stopAnim(),t.prototype.onZoomStart.call(this,e)},r.prototype.onZoomEnd=function(){this._animated=!0,this._computeGrid(),t.prototype.onZoomEnd.apply(this,arguments)},r.prototype._clearDataCache=function(){this._stopAnim(),delete this._markerExtent,delete this._markerPoints,delete this._clusterCache},r}(e.renderer.VectorLayerCanvasRenderer)),t.ClusterLayer=a,Object.defineProperty(t,"__esModule",{value:!0})}); \ No newline at end of file