如何从经度和纬度中找出地图图块坐标? [英] How to find out map tile coordinates from latitude and longitude?

查看:92
本文介绍了如何从经度和纬度中找出地图图块坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Mapbox矢量图块来收集来自后端进程的特定数据. 在示例中,它们提供了曼哈顿图块的链接:

I'm using Mapbox vector tiles to gather specific data from a backend process. In the examples, they provide a link of a Manhattan tile:

http://a.tiles. mapbox.com/v3/examples.map-zr0njcqy/14/4823/6160.png

成为图块 z / x / y 坐标 14 / 4823 / 6160

being the tile z/x/y coordinates 14/4823/6160

通过导航地图,我知道纬度 40.706119 和经度 -74.017554 的位置在该图块内部.

I know from navigating the map that the position of latitude 40.706119 and longitude -74.017554 is inside that tile.

我还从地图的工作原理中推断出 14中,整个地图由16384 x 16384个图块组成,即左上图块14/0/0.

I also deduct from how map works that working with zoom 14 the entire map is composed from 16384 x 16384 tiles being 14/0/0 the top left tile.

但是,将180度纬度和360度经度与总图块的行数和行数相乘,得出的结果是14/7464/4486,这不是同一张图块. (除非我做错了?)

Yet taking the 180 degrees of latitude and 360 of longitude with the total tile cols and rows gives me 14/7464/4486 which is not the same tile. (Unless I didn't do it right?)

问题

如何获取知道纬度和经度的图块坐标?

How do I get the tile coordinates knowing the latitude and longitude?

推荐答案

在mapbox-studio源代码中挖矿,我发现了这个小辅助对象:

Digging in mapbox-studio source code I've found this little helper object:

https://github.com/mapbox/mapbox- studio/blob/5ac2ead1e523b24c8b8ad8655babb66389166e87/ext/sphericalmercator.js

可以这样使用:

> var a = new SphericalMercator()
> a.xyz([-74.017554, 40.706119], 14)
Object { minX: 4823, minY: NaN, maxX: NaN, maxY: 6160 }

14 / 4823 / 6160

这篇关于如何从经度和纬度中找出地图图块坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆