Google Tile Server 中的平铺(x、y 和 z 参数)
我正在开发 Google Tile 服务器。我编写了一个 WCF 服务(C#),它使用 http URL 从 Google 服务器获取图块:- http://mt1.google.com/vt/lyrs=m@129&hl=en&x=1&y=0& z=1&s=Galileo
如您所知,Google Tile 需要在其 URL 中包含三个可变参数 x、y 和 z 来提供图块。
其他坐标可以在此处查看。
我非常成功地一一获取 Google Tile(地图)(意味着放置不同的 x、y 和 z 值)。
现在回到现实世界的场景,我尝试开发一个 WinForm (C#) 应用程序来显示这些图块。我能够显示一对一的图块。但我的问题是..
如何提供完整的地图集(不同的图块拼接在一起)? 我知道,我可以使用不同的参数向 Google Tile Server 提供多次调用,但我需要知道 x、y 和 y 的适当值是什么。 z 在不同的条件下并与之连续的关系
是否有任何计算、公式或映射将屏幕坐标链接到 Google Tile Server 坐标(指 x、y 和 z 值)?
我必须在拖动和双击时提供平滑的缩放和平移..与Google提供的相同。
我基本关心的是 Google 的 x、y、z 和我的屏幕坐标之间的关系。
任何帮助(或样品)将不胜感激。
I am working on Google Tile Server. I have written one WCF Service (C#) which fetches tile from Google server using http URL :- http://mt1.google.com/vt/lyrs=m@129&hl=en&x=1&y=0&z=1&s=Galileo
As you know, Google Tile requires three variable parameters x, y and z in it's URL to provide a tile.
Other co-ordinates can be seen here.
I am very much successful in fetching the Google Tile (Map) one by one (means putting different values of x, y and z).
Now coming to real world scenario, I tried developing one WinForm (C#) application to display those tiles. I am able to display one-one tiles. But my problem is..
How to provide complete set of maps (different tiles stitched together)?
I know, I can provide multiple calls to Google Tile Server with different parameters but I needed to know what could be the appropriate value of x, y & z in different conditions and continuous relation to thatIs there any calculation, formula or mapping which links screen coordinate to Google Tile Server coordinates (means x, y & z values)?
I have to provide smooth zooming and panning on dragging and double click .. same as Google provides.
My basic concern is relation between Google's x, y, z and my screen coordinates.
Any help (or samples) will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对你想要做的事情的解释很复杂,你必须以某种方式弄清楚它,因为事情不会简单地自动组装(这在某种程度上是不幸的)。
尽管如此,我发现以下链接确实解决了我的无知问题,所以现在我可以更容易地解决问题:
http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
这将解释(带有一些示例公式)如何获得您想要的转变。
The explanation for what you want to do is complicated, and you'd have to figure it out some way, because things don't simply assemble themselves automagically (which is unfortunate in a way).
Even though, I have found the following link literally solved my ignorance problem, so now I can figure things out much easier:
http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
This will explain (with some example formulas) how you can get your desired transformations.
您需要使用墨卡托投影从纬度/经度转到 Google 地图图块坐标(缩放、x、y)。请参阅 https://developers.google.com/maps/documentation/javascript/示例/地图坐标 为例。您首先需要从纬度/经度转换为“世界点”,然后根据缩放级别,您可以转换为整个虚拟地图图像上代表整个世界的像素。知道图块尺寸 (256 x 256) 后,您就可以将像素转换为图块坐标。
反转此逻辑以从图块坐标转到纬度/经度。
You need to use a Mercator projection to go from Latitude / Longitude to Google Maps tile coordinates (zoom, x, y). See https://developers.google.com/maps/documentation/javascript/examples/map-coordinates for an example. You will first need to convert from Lat / Lon to a "world point" and from there, based on the zoom level, you can convert to a pixel on the entire virtual map image that represents the whole world. Knowing the tile size (256 x 256), you can then convert from pixel to tile coordinates.
Reverse this logic to go from tile coordinates to Latitude / Longitude.
如果您想从经纬度转换为图块坐标,Bing 地图图块页面会为您提供所需的所有方程。 (假设每个人都使用左上角原点和 256x256 大小的图块)。
http://msdn.microsoft.com/en-us/library/bb259689.aspx
如果您需要使用不同尺寸的图块,请修改方程中的常数。
if you want to go from lat long to tile coordinates, the bing map tile page gives you all the equations you need. (assuming everyone is using a topleft origin, and 256x256 sized tiles).
http://msdn.microsoft.com/en-us/library/bb259689.aspx
if you need to use different sized tiles, then modify the constants in the equations.