百度地图点聚合和点动画一起使用

问题:不修改源码的情况下,点聚合和点动画一起使用的时候,会发现只要移动地图后,点动画就会消失

解决方法:

修改点聚合源码  =>  BMapLib_MarkerClusterer.js中的 _createClusters 方法

    MarkerClusterer.prototype._createClusters = function(){
        var mapBounds = this._map.getBounds();
        var extendedBounds = getExtendedBounds(this._map, mapBounds, this._gridSize);
        for(var i = 0, marker; marker = this._markers[i]; i++){
            if(!marker.isInCluster && extendedBounds.containsPoint(marker.getPosition()) ){ 
                this._addToClosestCluster(marker);
                if(marker.z.uj.imageUrl=='/prdltiot/resources/img/light-wrong.png'){//聚合点设置动画
    		    marker.setAnimation(BMAP_ANIMATION_BOUNCE);
                }
            }
        }   
    };

猜你喜欢

转载自blog.csdn.net/qq_35410544/article/details/83510547
今日推荐