如何使用地址打开Goog​​le地图?

use*_*635 11 java android google-maps google-maps-urls

如何使用地址打开Goog​​le地图(使用Intents或将Google地图添加到我的应用程序中)?我有地址,但我没有纬度/经度.我该怎么做?谢谢.

Mau*_*k J 39

使用下面的代码,

String map = "http://maps.google.co.in/maps?q=" + str_location; 
Run Code Online (Sandbox Code Playgroud)

//其中str_location是地址字符串

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(map));
        startActivity(i);
Run Code Online (Sandbox Code Playgroud)


st0*_*0le 14

来自我的个人代码库.;)

public static Intent viewOnMap(String address) {
    return new Intent(Intent.ACTION_VIEW,
                      Uri.parse(String.format("geo:0,0?q=%s",
                                              URLEncoder.encode(address))));
}

public static Intent viewOnMap(String lat, String lng) {
    return new Intent(Intent.ACTION_VIEW,
                      Uri.parse(String.format("geo:%s,%s", lat, lng)));
}
Run Code Online (Sandbox Code Playgroud)


Ash*_*ini 5

String geoUri = "http://maps.google.com/maps?q=loc:" + addressName;
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUri));
            context.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)