【发布时间】:2020-02-24 11:34:20
【问题描述】:
我有一张传单地图,其中包含带有经纬度元数据的卫星图像。我的目标是在鼠标点击时显示一个矩形突出显示选定的图块并获取相应的图块。 L.rectangle 方法需要边界来显示矩形。为了计算 SE 和 NW 角,我使用了在 https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Tile_numbers_to_lon..2Flat 找到的以下函数。
这是针对 SE 的,如上链接所示,为获取 NW 更改了相同的功能。这些用作矩形的边界。
//I have a fixed zoom level for my problem :4
function(xtile,ytile,zoom) //here i am giving the tile location coordinates as the input
{
n=2.0**zoom;
lon= (xtile+1)/n*360-180;
lat_rad=Math.atan(Math.Sinh(Math.PI*(1-2*(ytile+1)/n)));
lat=lat_rad(180/Math.PI);
return[-lat,lon]
}
输出如下:
NW -782.67,-112.4
SE -79.163,-89.9
with(suppose) xtile=5 and ytile=14
然而实际输出应该是:
NW -66.51,-45
SE -74.01,-22.5
and the corresponding(again,suppose) xtile=5 and ytile=1
所以基本上,对于某些瓷砖,矩形显示得很好。但对于其他人来说,它会跳转到其他一些图块。我有一个选定图块的显示窗口,当矩形跳转时,既不会获取选定图块,也不会提取突出显示的图块。如果有人可以帮助我,我将非常感激。
【问题讨论】:
标签: javascript leaflet