leaflet.TileLayer.WMTS icon indicating copy to clipboard operation
leaflet.TileLayer.WMTS copied to clipboard

Zoom level not being detected correctly

Open pfeely opened this issue 8 years ago • 1 comments

Not sure if this is related to a Leaflet version change (Using RC 1.0.0) or a bug in the plugin

The following function is assuming zoom as a second parameter

getTileUrl: function (tilePoint,zoom) { // (Point, Number) -> String

But zoom is undefined and not available.

Further down the code uses "zoom=map.getZoom();" - but this cannot be relied up because the getTileUrl function is fired before the zoom end event So when you zoom in and out it uses the old zoom level and gets the tile calculation wrong - which can throw an error from the WMTS service

Solution:

getTileUrl: function (tilePoint) { var map = this._map; var zoom = tilePoint.z; //Next zoom level

pfeely avatar Jul 13 '16 01:07 pfeely

Just went through this bug as well, I fixed it differently:

var zoom = (typeof map._animateToZoom == 'undefined') ? map.getZoom() : map._animateToZoom;

teriblus avatar Jul 22 '16 13:07 teriblus