用于谷歌地图(或类似)的 Java API

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/996954/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:02:47  来源:igfitidea点击:

Java API for Google Maps (or similar)

javagoogle-maps

提问by Savvas Dalkitsis

I was wondering if there is a Java library that acts as a wrapper for the Google Maps API. What I am interested in is displaying a satellite map of a specific region (lon, lat) on my desktop application. It doesn't have to be Google Maps specifically, any map service would do the trick.

我想知道是否有一个 Java 库可以作为 Google Maps API 的包装器。我感兴趣的是在我的桌面应用程序上显示特定区域(经度、纬度)的卫星地图。不一定非得是谷歌地图,任何地图服务都可以。

What I need though is a library to work with a desktop client, no javascript, GWT etc.

我需要的是一个与桌面客户端一起使用的库,没有 javascript、GWT 等。

Any ideas?

有任何想法吗?

采纳答案by RedBlueThing

If you are just looking to display a satellite map image for a specific latitude longitude (without the google maps panning/zooming etc), then you should check out Google Static Maps.

如果您只是想显示特定纬度经度的卫星地图图像(没有谷歌地图平移/缩放等),那么您应该查看谷歌静态地图

You just need to build a URL string, then make an HTTP request (from your java implementation) for the image (in whatever format you like). You can specify a whole bunch of parametersin the URL to get the satellite image you are after:

您只需要构建一个 URL 字符串,然后为图像(以您喜欢的任何格式)发出 HTTP 请求(来自您的 Java 实现)。您可以在 URL 中指定一大堆参数来获取您想要的卫星图像:

From the URL:

从网址:

http://maps.google.com/staticmap?center=40,26&zoom=1&size=150x112&maptype=satellite&key=ABQIAAAAgb5KEVTm54vkPcAkU9xOvBR30EG5jFWfUzfYJTWEkWk2p04CHxTGDNV791-cU95kOnweeZ0SsURYSA&format=jpg

EDIT: Ok, I actually deleted this answer because I discovered section 10.8 in the TOSexplicitly forbids accessing static maps from outside a browser. But then I discovered this FAQ updatewhich seems to allow it. I might ask a Google person and get the final word.

编辑:好的,我实际上删除了这个答案,因为我发现TOS 中的第 10.8 节明确禁止从浏览器外部访问静态地图。但后来我发现这个FAQ 更新似乎允许它。我可能会问一个谷歌的人并得到最后的结论。

EDIT: Thanks Paracycle, not sure if that is a new addition to the FAQ, but in any case it is pretty explicit, you are notallowed to do this.

编辑:谢谢Paracycle,不知道这是一个新增加的常见问题,但在任何情况下,这是很明确的,你是不是允许这样做

回答by Nate

You'll likely need to go with Microsoft Map Point Web Services. I don't know if Google offers something comparable w/out Javascript.

您可能需要使用 Microsoft Map Point Web 服务。我不知道 Google 是否提供了与 Javascript 类似的东西。

回答by mihi

embed a web browser control into your client, displaying a HTML page that uses the javascript API.

将 Web 浏览器控件嵌入您的客户端,显示使用 javascript API 的 HTML 页面。

Everything else will break eventually, since at least Google and Microsoft tend to change the link format for their aerial images regularly to make it harder to scrape them and store them offline (because they do not have bought licenses from the content providers for offline storage of these images).

其他一切最终都会破裂,因为至少谷歌和微软倾向于定期更改其航拍图像的链接格式,以便更难抓取它们并将它们离线存储(因为他们没有从内容提供商那里购买许可证以进行离线存储)这些图像)。

Other services (like Googles geolocation service) can easily used from Java, and "normal maps" work well as well, but aerials are tricky (at least they were when I tried it the last time), but of course doable if you are able to ship an update when the format changes...

其他服务(如 Google 的地理定位服务)可以很容易地从 Java 中使用,“法线地图”也可以很好地工作,但是天线很棘手(至少我上次尝试时是这样),但当然可以,如果可以的话在格式更改时发送更新...

edit: It might be different with the Google Maps for Enterprises service, but expect to pay a five-digit dollar amount for it...

编辑:它可能与 Google Maps for Enterprises 服务不同,但希望为此支付五位数的美元金额...

回答by Clint

Google maps does not allow for using it's images in desktop applications. Microsoft has a collaboration with USGS at http://terraserver-usa.com/. There is a freely available web servicewith a WSDL. You can use common Java WSDL binding libraries like Axisor CXFto create java object to access the service.

谷歌地图不允许在桌面应用程序中使用它的图像。Microsoft 在http://terraserver-usa.com/ 上与 USGS 合作。有一个免费提供的带有WSDL 的Web 服务。您可以使用常见的 Java WSDL 绑定库(如AxisCXF)来创建 Java 对象来访问服务。

Also, NASA has the World Windproject which has a Java API. The images are not the Google images but much of the Google images are based off of these images.

此外,NASA 拥有World Wind项目,其中包含一个 Java API。这些图像不是谷歌图像,但大部分谷歌图像都是基于这些图像。

回答by Thorbj?rn Ravn Andersen

Have a look at http://www.javaworld.com/javaworld/jw-01-2006/jw-0116-google.html. They describe how to work with Google Maps from Java and they have a war file (untested).

看看http://www.javaworld.com/javaworld/jw-01-2006/jw-0116-google.html。他们描述了如何从 Java 使用谷歌地图,并且他们有一个战争文件(未经测试)。

回答by matt b

You might want to take a look at the official Google Maps Data API, which I believe has a Java client. However I think this is just for retrieving/updating the "data" portion of Maps, so it would not give you access (which you probably aren't licensed to) for the actual photos.

您可能想看看官方的Google Maps Data API,我相信它有一个 Java 客户端。但是我认为这只是为了检索/更新地图的“数据”部分,因此它不会让您访问(您可能没有获得许可)实际照片。

回答by richardtallent

To see the literal map in your desktop app's window, you can embed a browser control that is Java-based and is compatible with the Google Maps application.

要在桌面应用程序的窗口中查看文字地图,您可以嵌入一个基于 Java 且与 Google 地图应用程序兼容的浏览器控件。

See this question to find out how to embed a browser in your Java app:

请参阅此问题以了解如何在您的 Java 应用程序中嵌入浏览器:

Embedding web browser window in Java

在 Java 中嵌入 Web 浏览器窗口

回答by Marios Neofitou

回答by Mark McDonald

Recently Google launched the Maps Services for Javalibrary, which brings support for the geocoding, directions, distance matrix, elevation and timezone APIs to Java.

最近 Google 推出了Maps Services for Java库,它为 Java带来了对地理编码、方向、距离矩阵、海拔和时区 API 的支持。