Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open Google Maps using address?

How can I open Google Maps(using Intents or adding Google Maps into my application) with address? I have the address, but I don't have latitude/longitude. How can I do it? Thank you.

like image 474
user1166635 Avatar asked Apr 03 '12 05:04

user1166635


People also ask

How do I turn an address into a link?

Add a hyperlink to existing textSelect the text that you want to turn into a hyperlink, and right-click it. On the shortcut menu, click Hyperlink. In the Insert Hyperlink dialog, paste the link in the Address box and click OK.


2 Answers

use below code,

String map = "http://maps.google.co.in/maps?q=" + str_location; 

// where str_location is the address string

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(map));
        startActivity(i);
like image 95
Maulik J Avatar answered Sep 27 '22 21:09

Maulik J


From my personal Code Library. ;)

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)));
}
like image 31
st0le Avatar answered Sep 27 '22 23:09

st0le