gLayers.Leaflet icon indicating copy to clipboard operation
gLayers.Leaflet copied to clipboard

Animated features issues when moving/dragging the map

Open Diego251 opened this issue 7 years ago • 1 comments

Hello, having an issue with the custom layer, on which I am trying to draw animated circles. Basically, the issue happens when I move (pan/drag) the map. Extended details are here:

https://stackoverflow.com/questions/51156212/leaflet-canvaslayer-how-to-get-animated-features-to-move-correctly-when-dragg

Is there something very obvious I am missing? Thank you for your help!

Diego251 avatar Jul 03 '18 17:07 Diego251

Same here (I am using "leaflet": "^1.7.1"). I think it is related to the L.DomUtil.setPosition(this._canvas, topLeft); in:

_onLayerDidMove: function () {
    var topLeft = this._map.containerPointToLayerPoint([0, 0]);
    L.DomUtil.setPosition(this._canvas, topLeft);
    this.drawLayer();
},

It does move the canvas back which is needed for the drawLayer but it updates the view already. I tried following code WITHOUT success:

    const opacity = L.DomUtil.getStyle(this._canvas, 'opacity');
    L.DomUtil.setOpacity(this._canvas, '0');
    var topLeft = this._map.containerPointToLayerPoint([0, 0]);
    L.DomUtil.setPosition(this._canvas, topLeft);
    this.drawLayer();
    L.DomUtil.setOpacity(this._canvas, opacity);

BTW I think a setTransform would do the job instead of the setPosition.

CoooWeee avatar Jan 14 '21 02:01 CoooWeee