如何获取静态Google地图的界限? [英] how do I get the bounds of a static google map?
问题描述
我正在绘制通过Google搜索静态Map API检索的图像上的地理坐标(lat / lon)。我想通过Ruby直接在图像上离线,因为我想绘制大约20,000个坐标。
然而,对于这个任务,我需要指定一个角左和右下)坐标。
这里是我的地图链接:
http://maps.google.com/staticmap?center=51.0,10.0&zoom=6&size=640x640&format=png&sensor=false
如何获取此地图左上角和右下角的坐标?
提前感谢:)
PS:我的代码为Lat / Lon - > X / Y是这个现在:
def get_img_coords(lat,lon,w,h,lat_ul,lon_ul,lat_lr,lon_lr)
{:x => (lon + lon_ul)*(w /(lon_lr-lon_ul)),
:y => (lat + lat_ul)*(h /(lat_lr-lat_ul))}
end
...当然是假设投机者。
我以前遇到过这个问题。上次我检查了(一年以前有一点),Maps API通过Geohashing编码了大部分信息。我建议您先看看维基百科页面,然后查看这个其他的stackoverflow问题,它似乎有一个Java实现你想要的。
I am trying to plot geo coordinates (lat/lon) on an image I retrieve via Googles static Map API. I want to do this offline directly on the image via Ruby because I want to plot about 20,000 coordinates.
However, for this task, I need to specify the corner (top left & bottom right) coordinates. here is the link to my map: http://maps.google.com/staticmap?center=51.0,10.0&zoom=6&size=640x640&format=png&sensor=false
How can I get coordinates for the top left and bottom right corners of this map?
Thanks in advance :)
PS: My code for Lat/Lon -> X/Y is this for now:
def get_img_coords(lat, lon, w, h, lat_ul, lon_ul, lat_lr, lon_lr)
{ :x => (lon + lon_ul) * (w / (lon_lr-lon_ul)),
:y => (lat + lat_ul) * (h / (lat_lr-lat_ul)) }
end
... assuming mercator projection of course.
I ran into this problem before. Last time I checked (which was a bit over a year ago), the Maps API encoded most of its information via Geohashing. I suggest you start by looking at the Wikipedia page for it, and see this other stackoverflow question, which appears to have a Java implementation of what you want.
这篇关于如何获取静态Google地图的界限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!