[英]Latitude and longitude to map tile set
On the link below [1] I can see how to get the URL of the tile for specific latlon.在下面的链接 [1] 上,我可以看到如何获取特定 latlon 的图块 URL。
var zoom = 15;
var lat = 47;
var lon = 8;
function long2tile(lon,zoom) { return (Math.floor((lon+180)/360*Math.pow(2,zoom))); }
function lat2tile(lat,zoom) { return (Math.floor((1-Math.log(Math.tan(lat*Math.PI/180) + 1/Math.cos(lat*Math.PI/180))/Math.PI)/2 *Math.pow(2,zoom))); }
var x = long2tile(lon, zoom); // get x long2tile
var y = lat2tile(lat, zoom); // get y lat2tile
tileUrl = "tile.osm.org/" + zoom + "/" + x + "/" + y + ".png"
What I want to know is how to get all the tile URL's for the surrounding tiles.我想知道的是如何获取周围瓷砖的所有瓷砖 URL。 Usually there is a grid of say 3x3 tiles and I'm looking in the one in the middle, that would be my base latlon.
通常有一个说 3x3 瓷砖的网格,我正在寻找中间的那个,那将是我的基本 latlon。 How do I get URL's for all the other neighboring tiles?
如何获取所有其他相邻图块的 URL?
[1] http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#ECMAScript_.28JavaScript.2FActionScript.2C_etc..29 [1] http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#ECMAScript_.28JavaScript.2FActionScript.2C_etc..29
These are just coordinates in a grid.这些只是网格中的坐标。 Increase/decrease your x and y coordinates accordingly to get all surrounding tiles.
相应地增加/减少您的 x 和 y 坐标以获取所有周围的瓷砖。 Example:
例子:
Quoting from the Wiki:引自维基:
- X goes from 0 (left edge is 180 °W) to 2^zoom − 1 (right edge is 180 °E)
X 从 0(左边缘为 180°W)到 2^zoom − 1(右边缘为 180°E)
- Y goes from 0 (top edge is 85.0511 °N) to 2^zoom − 1 (bottom edge is 85.0511 °S) in a Mercator projection
在墨卡托投影中,Y 从 0(顶部边缘为 85.0511 °N)到 2^zoom − 1(底部边缘为 85.0511 °S)
For the curious, the number 85.0511 is the result of arctan(sinh(π)).
对于好奇,数字 85.0511 是 arctan(sinh(π)) 的结果。 By using this bound, the entire map becomes a (very large) square.
通过使用这个边界,整个地图变成了一个(非常大的)正方形。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.