From 29a0eaef0fc5fab2fe681d0c5fbd1cd662e2e629 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 20 Mar 2014 13:58:15 -0700 Subject: [PATCH] include zoom in tile coords, simplify parsing tile keys --- src/layer/tile/GridLayer.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/layer/tile/GridLayer.js b/src/layer/tile/GridLayer.js index 860001c3..627fff68 100644 --- a/src/layer/tile/GridLayer.js +++ b/src/layer/tile/GridLayer.js @@ -372,6 +372,10 @@ L.GridLayer = L.Layer.extend({ return L.latLngBounds(this.options.bounds).intersects(tileBounds); }, + _keyToBounds: function (key) { + return this._tileCoordsToBounds(this._keyToTileCoords(key)); + }, + // converts tile coordinates to its geographical bounds _tileCoordsToBounds: function (coords) { @@ -389,16 +393,15 @@ L.GridLayer = L.Layer.extend({ // converts tile coordinates to key for the tile cache _tileCoordsToKey: function (coords) { - return coords.x + ':' + coords.y; + return coords.x + ':' + coords.y + ':' + coords.z; }, // converts tile cache key to coordinates _keyToTileCoords: function (key) { - var kArr = key.split(':'), - x = parseInt(kArr[0], 10), - y = parseInt(kArr[1], 10); - - return new L.Point(x, y); + var k = key.split(':'), + coords = new L.Point(+k[0], +k[1]); + coords.z = +k[2]; + return coords; }, // remove any present tiles that are off the specified bounds