使用 Java 在 Google 地图中打开一个位置

Open a location in Google Maps using Java

我想从我的 Java 应用程序在 Google 地图中打开一个位置。我在这样的字符串中得到了纬度和经度:

String latitude = "47.272529";     // String for latitude
String longitude = "7.755237";     // String for longitude

如何为该位置生成正确的 Google 地图 link 以及如何从我的源代码中打开它?它应该是这样的:

openURL("www.maps.google.com/"+latitude+"/"+longitude);    // Open URL

我用了url

以下为实际情况android

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr=Current%20Location&daddr=52.5651667, -8.7895846"));
startActivity(browserIntent)

这将为您提供在浏览器或 google 地图应用程序中打开的选项

这应该适用于 Java

try {



                Desktop.getDesktop().browse(new URI("http://maps.google.com/maps?saddr=Current%20Location&daddr=52.5651667, -8.7895846"));
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (URISyntaxException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }