指定纬度&渴望单张瓷砖 [英] Specifying Lat & Long for Leaflet TileLayer

查看:97
本文介绍了指定纬度&渴望单张瓷砖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎是一个简单的问题,但是我已经把头发拉了好几个小时了.

我有一系列文件,即

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左右.

因此,我想指定图像起源的纬度和经度,以及图像应从哪个缩放级别开始.我尝试了边界(不显示任何内容),并且尝试了补偿缩放级别.

我需要这样做,因为用户需要单击离线地图以指定他们的位置,并且我需要GPS坐标.

我也有一个KML文件,但在地图上绘制矢量数据似乎更有帮助.

非常感谢您的帮助,

解决方案

如果我正确理解,您拥有的"kml_image_Lz_x_y.jpg"图像实际上是图块,其文件名中具有缩放,水平和垂直索引? >

您的问题是,它们使用(z,x,y)的数字就像从最高层开始(缩放0,整个世界使用单个图块)一样,但实际上它们只是其中的一小部分瓷砖金字塔?

您不能按原样使用它们,因为您仍然想获取实际的地理坐标(纬度,经度),如果您像使用瓷砖一样显示整个世界,那将是完全错误的?

在这种情况下,您有几种解决方法:

最简单,最可靠的方法可能是简单地编写一个小脚本,以重命名所有图块为它们的真实(z,x,y)数字.

另一种选择是在将(z,x,y)数字写入图块src属性之前对其进行修改,并应用适当的偏移量(对于z恒定,对于x和y用z缩放).这可能应该发生在 L.TileLayer.getTileUrl()方法.

祝你好运! :-)

Seems like a simple question, but I have been tearing my hair out for hours now.

I have a series of files ie.

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

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.

I need this because a user needs to click on an offline map to specify where they are and I need the GPS coordinates.

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.

解决方案

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?

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:

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.

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.

Good luck! :-)

这篇关于指定纬度&渴望单张瓷砖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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