我想做的事:
我想用 Java 创建一个小程序(这里是 Java 初学者),在其中指定 GPS 位置和缩放级别并下载 Google map 显示的 map 图像。与此相关的是,我需要有一个与图像相关的比例(矩形图像的 x 和 y 尺寸的尺寸,以 Km 为单位)。
我所知道的:
我知道如何在浏览器中显示正确的图像,直接在 URL 中指定 GPS 位置和缩放级别(例如: https://maps.google.com/maps?f=q&hl=de&geocode=&q=48.167432,+10.533072&z=7 )。 Python 中应该有某种类似 urllib 的库,我可以用它来调用这个 URL。
如何下载该图像,以及如何知道其中所描绘的区域? 我实际上找到了一个公式来关联像素中“包含”的米数(或任何单位)(该函数取决于 map 的纬度和缩放级别)。这种情况下,如何知道 map 使用的像素呢?
感谢您的任何建议和/或指示!
最佳答案
您想要使用静态 map API。
https://developers.google.com/maps/documentation/staticmaps/index
您的特定 map 位于 URL
http://maps.googleapis.com/maps/api/staticmap?center=48.167432,10.533072&size=400x400&sensor=true&zoom=7
只是一张图片。如果您使用 GPS 传感器查找位置,请设置sensor=true。否则将其设置为 false。
要从此网址读取图像:
How to then download this image, and how to know the area pictured in it? I actually found a formula to relate the amount of meters (or whatever unit) "contained" in a pixel (this function depends on latitude and zoom level of the map). In this case, how to know about the pixels used by the map?
您将像素和缩放级别传递到图像中,以便此解决方案提供所有信息,因此您的比例应该很容易计算。
关于java - 使用 Java 使用 Google Map 下载 map 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18990234/