在 Java 桌面应用程序中嵌入谷歌地图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19701105/
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
Embed google maps in Java desktop Application
提问by satnam
I want to embed google maps on a JPanel. Since I want features like zoom-in/out, using static images isn't feasible.
我想在 JPanel 上嵌入谷歌地图。由于我想要放大/缩小等功能,因此使用静态图像是不可行的。
To achieve this, I'll probably need to embed a webpage (which displays google maps) in my Java desktop application. And I've read that I'll need something like WebKit (alternatives?) to accomplish this.
为了实现这一点,我可能需要在我的 Java 桌面应用程序中嵌入一个网页(显示谷歌地图)。我已经读到我需要像 WebKit(替代品?)这样的东西来完成这个。
I'd appreciate any help that'll help me:
我很感激任何对我有帮助的帮助:
- Embed a webpage in a Jpanel.
- That webpage to display google maps.
- 在 Jpanel 中嵌入网页。
- 该网页显示谷歌地图。
采纳答案by Imran
Yes, the Google Maps APIs can now be used in Desktop applications
是的,Google Maps API 现在可以在桌面应用程序中使用
Check out these Stack Overflow threads:
查看这些 Stack Overflow 线程:
Embedding Gecko/Webkit in Java
Rendering webpages with WebKit in Java
You can also see the tutorailof using Maps in Java Desktop Application.
您还可以查看在 Java 桌面应用程序中使用地图的教程。
回答by Vitaly Eremenko
You can use JxMapslibrary to complete this task. It has Swing component which can be simply embedded to JPanel
.
您可以使用JxMaps库来完成此任务。它具有 Swing 组件,可以简单地嵌入到JPanel
.
void createMapView(JPanel parent) {
MapView view = new MapView();
parent.add(view);
}
This library has comprehensive set of classes for working with Google Maps from java.
这个库有一组全面的类,用于从 java 处理谷歌地图。