From 4196e34c73dec342e2c60970c8460fa6f78c1454 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Thu, 28 May 2015 18:52:35 +0200 Subject: [PATCH] Improve doucmentation for ol.TileUrlFunctionType --- src/ol/tileurlfunction.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/ol/tileurlfunction.js b/src/ol/tileurlfunction.js index 28382f33fa..cd22b62756 100644 --- a/src/ol/tileurlfunction.js +++ b/src/ol/tileurlfunction.js @@ -14,6 +14,28 @@ goog.require('ol.tilecoord'); * for the projection as arguments and returns a `{string}` or * undefined representing the tile URL. * + * The {@link ol.TileCoord}'s `x` value + * increases from left to right, `y` increases from bottom to top. At the + * bottom left corner, `x` and `y` are `0`. To convert `y` to increase from + * top to bottom, use the following code: + * ```js + * var tileGrid = new ol.tilegrid.TileGrid({ + * extent: extent, + * resolutions: resolutions, + * tileSize: tileSize + * }); + * + * function calculateY(tileCoord) { + * var z = tileCoord[0]; + * var yFromBottom = tileCoord[2]; + * var resolution = tileGrid.getResolution(z); + * var tileHeight = ol.size.toSize(tileSize)[1]; + * var matrixHeight = + * Math.floor(ol.extent.getHeight(extent) / tileHeight / resolution); + * return matrixHeight - yFromBottom - 1; + * }; + * ``` + * * @typedef {function(ol.TileCoord, number, * ol.proj.Projection): (string|undefined)} * @api