onaci/leaflet-geotiff-2

layer jumps position when moving map

Opened this issue · 3 comments

On firefox and safari, when the map is moved (pan), the layer jumps on the map. You can see this with the demo site:

https://danwild.github.io/leaflet-geotiff-2/

In _reset(), L.DomUtil.setPosition() moves the layer to the wrong place, then setting this._image.src in _drawImage() moves it back.

Seems ok on chrome desktop but not chrome ipad.

I think that the problem is the way that these browsers manage the styles update. They are supposedly to update styles when javascript execution is finished, but the styles are updated when the line of code is executed, so it flickers.
A double-buffer approach could be used to avoid this, but I think that it would be faster only to create an image with the full ndvi render and plot it with css.

Can this be solved with the current build or is inner-work needed?

AFAIK, changes should be done in the javascript engine, telling them not to process the change during the script execution.
If I come up with some workaround, I will post it in here.

P.D.: This could be solved also by rendering the whole image and transforming it using CSS. I have a POC in my fork of this repo, under the direct-render branch.