问题描述
似乎是一个简单的问题,但我已经扯了几个小时的头发了.
Seems like a simple question, but I have been tearing my hair out for hours now.
我有一系列文件,即.
kml_image_L1_0_0.jpg
kml_image_L2_0_0.jpg
kml_image_L2_0_1.jpg
kml_image_L2_1_0.jpg
kml_image_L2_1_1.jpg
等等.然而,将它们绘制在传单地图表面上可以理解地将图像置于地球表面的 0,0 处,并且文件推断的 0 缩放级别实际上应该约为 15 左右.
etc. However just plotting them on the leaflet map surface understandibly puts the images at 0,0 on the earths surface, and the 0 zoom level inferred by the files should really be about 15 or so.
所以我想指定图像应该起源的纬度和经度,以及它们应该从什么缩放级别开始.我已经尝试过边界(不显示任何内容)并且我尝试过使用偏移缩放级别.
So I want to specify the latitude and longitude where the images should originate , and what zoom level they should start at. I have tried bounds (which doesn't display anything) and I have tried playing with offsetting the zoom level.
我需要这个,因为用户需要点击离线地图来指定他们的位置,而我需要 GPS 坐标.
I need this because a user needs to click on an offline map to specify where they are and I need the GPS coordinates.
我也有一个 KML 文件,但它似乎对在地图上绘制矢量数据更有帮助.
I also have a KML file but it seems to be of more help for plotting vector data on the map.
非常感谢任何帮助,干杯.
Any help is much appreciated, cheers.
推荐答案
如果我理解正确,您拥有的kml_image_Lz_x_y.jpg"图像实际上是平铺,文件名中有缩放、水平和垂直索引?
If I understand correctly, the "kml_image_Lz_x_y.jpg" images that you have are actually tiles, with zoom, horizontal and vertical indices in their file name?
您的问题是他们使用 (z,x,y) 数字,就好像他们从最顶层开始(缩放 0,整个世界的单个图块),但实际上它们只是瓷砖金字塔?
And your issue is that they use (z,x,y) numbers as if they started from the top-most level (zoom 0, single tile for entire world), but in fact they are just a small portion of the pyramid of tiles?
而且您不能按原样使用它们,因为您仍然想获得实际的地理坐标(纬度、经度),如果您使用瓷砖就好像它们展示了整个世界,这将是完全错误的?
And you cannot use them as is because you still want to get actual geographic coordinates (latitude, longitude), which would be totally wrong if you used the tiles as if they were showing the entire world?
在这种情况下,您有多种解决方法:
In that case, you have several options as workarounds:
最简单和可靠的方法可能是简单地编写一个小脚本,将所有图块重命名为它们的真实 (z,x,y) 数字.
The most simple and reliable would probably be to simply write a small script to rename all your tiles to their true (z,x,y) numbers.
另一种选择是在写入 tile src 属性之前修改 (z,x,y) 数字,并应用适当的偏移量(z 为常数,x 和 y 由 z 缩放).这可能应该发生在 L.TileLayer.getTileUrl()
方法.
Another option would be to modify the (z,x,y) numbers before they are written in the tile src attribute, and apply the appropriate offset (constant for z, scaled by z for x and y). That should probably happen in L.TileLayer.getTileUrl()
method.
祝你好运!:-)
这篇关于指定纬度 &渴望传单 TileLayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!