简体   繁体   English

Java Dekstop应用程序中的Google Maps

[英]Google Maps in a Java Dekstop Application

I want to develop a java application using google maps that let the user add navigate using a map and add waypoints, and also I want to retrieve the latitude and longitude information from those waypoints, my question is if it is possible, I have been reading about many API's or external jars for doing this but recently I find out this Google Maps Services Java and don't know if it is enough to let me do that work, so, anyone know if it is possible with this new API? 我想使用Google Maps开发一个Java应用程序,该应用程序允许用户使用地图添加导航并添加航路点,而且我想从这些航路点检索纬度和经度信息,我的问题是是否有可能,我一直在阅读关于许多API或外部jar的信息,但最近我发现了Google Maps Services Java ,不知道是否足以让我完成这项工作,所以,有人知道使用此新API是否可行? or should I use an external work? 还是应该使用外部作业? thank you. 谢谢。

I know this answer is coming a year later, but try using the JxBrowser library. 我知道这个答案将在一年后出现,但是请尝试使用JxBrowser库。 I've found it to be the best library from what is already out there. 我发现它是现有的最好的库。

https://sites.google.com/a/teamdev.com/jxbrowser-support/home https://sites.google.com/a/teamdev.com/jxbrowser-support/home

They only give you a free 30 day trial with the license for their library, however I've personally found it to be very helpful. 他们只会为您免费提供30天的带库许可的试用版,但是我个人认为这非常有帮助。 Once you download all the JAR files and import them into your project (I used Eclipse, but you can use whatever), import the following code: 一旦下载了所有JAR文件并将其导入到您的项目中(我使用Eclipse,但是您可以使用任何东西),请导入以下代码:

package com.mycompany.myproduct;

import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;

import javax.swing.*;
import java.awt.*;

public class BrowserSample {
   public static void main(String[] args) {
    Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.add(browserView, BorderLayout.CENTER);
    frame.setSize(700, 500);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    browser.loadURL("http://maps.google.com");
    }
}

Once you run this, you'll get a default view of Google Maps as you would if you were to go to the actual web link in Chrome or Safari. 运行此命令后,您将获得默认的Google Maps视图,就像您要转到Chrome或Safari中的实际Web链接一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM