Skip to content

Conversation

zmbc
Copy link

@zmbc zmbc commented Dec 12, 2020

When using maxZoom and maxNativeZoom to "overzoom" tiles to higher zoom levels, the existing Canvas.Tile logic incorrectly calculates where the mouse is within the tile, because it does not scale the real pixels to the canvas' pixels, which are now 2, 4, 8, etc times larger. This means that features cannot be hovered or clicked on.

This commit adds logic to scale offsets and mouse locations according to the overzoom factor, which restores the behavior of non-overzoomed tiles.

When using maxZoom and maxNativeZoom to "overzoom" tiles to higher zoom
levels, the existing Canvas.Tile logic incorrectly calculates where the
mouse is within the tile, because it does not scale the real pixels to
the canvas' pixels, which are now 2, 4, 8, etc times larger. This means
that features cannot be hovered or clicked on.

This commit adds logic to scale offsets and mouse locations according to
the overzoom factor, which restores the behavior of non-overzoomed tiles.
},

getOverZoomFactor: function() {
var numberOfZoomLevels = Math.max(0, this._map.getZoom() - this._tileCoord.z);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a case in leaflet fractional zooming where the tiles are "underzoomed".
So this._map.getZoom() is smaller than _tileCoord.z.
By Removing the "0"-Limit "underzoomed" cases will work as well.

Suggested change
var numberOfZoomLevels = Math.max(0, this._map.getZoom() - this._tileCoord.z);
var numberOfZoomLevels = this._map.getZoom() - this._tileCoord.z;

This Case happens when using zoomSnap of 0.25. Fractions < 0.5 take overzoom, Fractions >= 0.5 underzoom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants