java 我想在我的桌面应用程序中使用 Google Map API

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2867276/
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-10-29 23:12:32  来源:igfitidea点击:

I want to use Google Map API for my Desktop application

javagoogle-maps

提问by Nubkadiya

I want to use google map API for my desktop application. The application will be totally connected to the internet.

我想在我的桌面应用程序中使用谷歌地图 API。该应用程序将完全连接到互联网。

While I was searching some research notes about this implementation. I found a ideal site with the configurations, but it has some java files to be downloaded, but when I tried that website its not loading. which is swinglabs.org

当我在搜索有关此实现的一些研究笔记时。我找到了一个带有配置的理想站点,但它有一些 java 文件要下载,但是当我尝试该网站时,它没有加载。这是swinglabs.org

http://today.java.net/pub/a/today/2007/10/30/building-maps-into-swing-app-with-jxmapviewer.html

http://today.java.net/pub/a/today/2007/10/30/building-maps-into-swing-app-with-jxmapviewer.html

Any other options of doing this api implementation to my desktop application? and one more thing. I tried downloading the google api. even it ask a url.We have to provide a url then only we get a key to download it. And the api should run in that specific url. Otherwise, its not working. How this appears to a desktop application

对我的桌面应用程序执行此 api 实现的任何其他选项?还有一件事情。我尝试下载 google api。甚至它会询问一个 url。我们必须提供一个 url,然后我们才能获得下载它的密钥。并且 api 应该在该特定 url 中运行。否则,它不工作。这在桌面应用程序中的显示方式

any ideas welcome.

欢迎任何想法。

采纳答案by npinti

At the moment it is illegal to use the JXMapViewer with google maps, reason being that this component requires direct access to Google's tile server. According to Google's ToC:

目前将 JXMapViewer 与 google 地图一起使用是非法的,原因是该组件需要直接访问 Google 的 tile 服务器。根据谷歌的 ToC:

Can I access the Maps and Satellite images directly?

You may not access the maps or satellite images through any mechanism besides the Google Maps APIs (such as the creation of your own mapping API or the use of a bulk tile download script). Your application's access to the tiles will be blocked if it accesses them outside of the Google Maps APIs. See section 5.3 of the Google Terms of Use for more details.

我可以直接访问地图和卫星图像吗?

您不得通过除 Google Maps API 之外的任何机制(例如创建您自己的地图 API 或使用批量图块下载脚本)访问地图或卫星图像。如果您的应用程序在 Google Maps API 之外访问图块,则它对图块的访问将被阻止。有关详细信息,请参阅 Google 使用条款的第 5.3 节。

More information can be found here. You should be able to download the packages from here. They moved the domain and many sites still point to the old domain, hence taking you nowhere.

可以在此处找到更多信息。您应该可以从这里下载软件包。他们移动了域,许多站点仍然指向旧域,因此您无处可去。

Currently the only way you can use the JXMapViewer by displaying maps from OpenStreetMap.

目前您可以通过显示来自OpenStreetMap 的地图来使用 JXMapViewer 的唯一方法。

You can, however, display static maps on your application. You basically build a URL. This tutorialshould give you a basic idea on how to be able to build a URL to be able to request static maps. You then use an HTTP Get request to get the image back.

但是,您可以在应用程序上显示静态地图。您基本上构建了一个 URL。本教程应该让您对如何构建一个能够请求静态地图的 URL 有一个基本的了解。然后使用 HTTP Get 请求取回图像。

Last but not least, Google is planning on allowing direct access to their tile servers, but this might take a while.

最后但并非最不重要的一点是,谷歌计划允许直接访问他们的磁贴服务器,但这可能需要一段时间。

回答by Silver Moon

You can use google maps in desktop applications.

您可以在桌面应用程序中使用谷歌地图。

For this you need to embed a browser in your application and then open up html/javascript files which render a map.

为此,您需要在应用程序中嵌入浏览器,然后打开渲染地图的 html/javascript 文件。

Different languages and api provide ways to embed a browser. For example wxwidgets/c++ has a widget called WebView which allows to embed webkit on linux and trident on windows. Similary mfc/c# also allow the same. So checkout how to embed a browser into your application.

不同的语言和 api 提供了嵌入浏览器的方法。例如 wxwidgets/c++ 有一个名为 WebView 的小部件,它允许在 linux 上嵌入 webkit,在 windows 上嵌入 trident。类似的 mfc/c# 也允许相同。因此,请查看如何将浏览器嵌入到您的应用程序中。

The api should also provide a way to execute javascript code in the embedded browser. Then you can modify the google map through the code of the application as and when needed.

api 还应该提供一种在嵌入式浏览器中执行 javascript 代码的方法。然后您可以在需要时通过应用程序的代码修改谷歌地图。

回答by Marcus Adams

I have a desktop application that calls a similar API. They require the API calls to come from one particular domain (and URL). So, I have the desktop app contact my own web server, which calls the third party API and returns the results.

我有一个调用类似 API 的桌面应用程序。它们要求 API 调用来自一个特定的域(和 URL)。所以,我让桌面应用程序联系我自己的 Web 服务器,它调用第三方 API 并返回结果。