How to open Google Maps using an address?

How do I open Google Maps (using intentions or add Google Maps to my application) with an address? I have an address, but I do not have latitude / longitude. How can I do it? Thanks.

+11
source share
7 answers

use below code

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

// where str_location is the address bar

 Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(map)); startActivity(i); 
+37
source

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))); } 
+14
source

Change the bold portion of this URL to your company address. It’s best if you replace all spaces with a plus sign (+), but should also work with spaces: http://maps.google.com/maps/geo?q= 620 + 8th + Avenue, + New + York, + NY + 10018, + USA and output = & CSV amplifier; ay = utf8 & amp; sensor = false

Confirm the request to the above URL. For more information see http://androidadvice.blogspot.in/2010/09/asynchronous-web-request.html

This will create code that looks something like this:

 200,8,40.7562008,-73.9903784 

The first number, 200, says the address is good. The second number, 8, indicates how accurate the address is. The last two numbers, 40.7562008 and -73.9903784, are the latitude and longitude of this address. Use them to make your Google map work.

Note. The above steps were copied from http://webdesign.about.com/od/javascript/ss/add-google-maps-to-a-web-page_2.htm

+1
source

You can use the Google geocoding API, which converts your physical address to latitude and longitude. The API returns it in XML or JSON format. You just need to analyze the data to get latitude and longitude. After receiving the latitude and longitude, you can upload it to mapview.

Link to geocoding api:

https://developers.google.com/maps/documentation/geocoding/

Hope this helps.

0
source

As of 2017, recommended by Google, the Google Maps API is used, which provides universal cross-platform URLs. You can use these URLs for your own purposes.

An example of such a URL from the documentation:

https://www.google.com/maps/search/?api=1&query=centurylink+field

Hope this helps!

0
source

A bit late for the party. I prefer @ st0le's answer, but URLEncoder.encode(String s) deprecated with API 16. You also need to pass a second argument. Check out the answer below.

  public static Intent viewOnMapA(String address) { try { return new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("geo:0,0?q=%s", URLEncoder.encode(address, "UTF-8")))); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; } 
0
source
 String geoUri = "http://maps.google.com/maps?q=loc:" + addressName; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUri)); context.startActivity(intent); 
0
source

All Articles