From cca6b47fc01cedd533c5dcdb72a4e22a5dde138e Mon Sep 17 00:00:00 2001 From: Antoine Vandecreme Date: Sun, 9 Oct 2016 14:05:22 +0200 Subject: [PATCH] Fix TileSource.getTileAtPoint --- src/tilesource.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/tilesource.js b/src/tilesource.js index eb5aabc0..fd0084c4 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -344,12 +344,13 @@ $.TileSource.prototype = { * @param {Number} level * @param {OpenSeadragon.Point} point */ - getTileAtPoint: function( level, point ) { - var numTiles = this.getNumTiles( level ); - return new $.Point( - Math.floor( (point.x * numTiles.x) / 1 ), - Math.floor( (point.y * numTiles.y * this.dimensions.x) / this.dimensions.y ) - ); + getTileAtPoint: function(level, point) { + var widthScaled = this.dimensions.x * this.getLevelScale(level); + var pixelX = point.x * widthScaled; + var pixelY = point.y * widthScaled; + var x = Math.floor(pixelX / this.getTileWidth()); + var y = Math.floor(pixelY / this.getTileHeight()); + return new $.Point(x, y); }, /**