alexandre-melard / leaflet.TileLayer.WMTS

Add WMTS layering for leaflet
Other
78 stars 84 forks source link

Zoom level not being detected correctly #9

Open pfeely opened 8 years ago

pfeely commented 8 years ago

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

teriblus commented 8 years ago

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

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