diff --git a/src/map/baidu-map/CanvasLayer.js b/src/map/baidu-map/CanvasLayer.js index c24049bf..5a979a6f 100644 --- a/src/map/baidu-map/CanvasLayer.js +++ b/src/map/baidu-map/CanvasLayer.js @@ -73,15 +73,10 @@ if (global.BMap) { CanvasLayer.prototype._draw = function() { var map = this._map; - var size = map.getSize(); - var center = map.getCenter(); - if (center) { - var pixel = map.pointToOverlayPixel(center); - this.canvas.style.left = pixel.x - size.width / 2 + 'px'; - this.canvas.style.top = pixel.y - size.height / 2 + 'px'; - this.dispatchEvent('draw'); - this.options.update && this.options.update.call(this); - } + this.canvas.style.left = - map.offsetX + 'px'; + this.canvas.style.top = - map.offsetY + 'px'; + this.dispatchEvent('draw'); + this.options.update && this.options.update.apply(this, arguments); } CanvasLayer.prototype.getContainer = function() { diff --git a/src/map/baidu-map/Layer.js b/src/map/baidu-map/Layer.js index e453049f..9f5e8830 100644 --- a/src/map/baidu-map/Layer.js +++ b/src/map/baidu-map/Layer.js @@ -43,6 +43,13 @@ class Layer extends BaseLayer{ }); } + + throttle(fun, ctx, pixel, e) { + clearTimeout(fun.tId) + fun.tId = setTimeout(function(){ + fun.call(ctx, pixel, e); + }, 300); + } clickEvent(e) { var pixel = e.pixel; @@ -51,7 +58,8 @@ class Layer extends BaseLayer{ mousemoveEvent(e) { var pixel = e.pixel; - super.mousemoveEvent(pixel, e); + this.throttle(super.mousemoveEvent, this, pixel, e); + // super.mousemoveEvent(pixel, e); } bindEvent(e) {