1

Possible Duplicate:
Reverse Geocoding With Google Map API And PHP To Get Nearest Location Using Lat,Long coordinates

How to convert gps coordinates ( latitude&longitude ) to address on Android or Php ?

My program should get address from given coordinates. For example :

Coordinates : 41.011576, 28.984852 --> Address : Cankurtaran Mh., Kennedy Cd, Istanbul, Türkiye

I hope, you can help me..

Community
  • 1
  • 1
iremce
  • 570
  • 4
  • 14
  • 25

2 Answers2

6

The Geocoder class can do what you want for Android. You would use getFromLocation You would do it as so:

    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
    Address adress;
    String result = null;
    List<Address> list = geocoder.getFromLocation(latitude, longitude, 1);
    address = list.get(0);
    result = address.getAddressLine(0) + ", " + address.getLocality();
    //Now do what you want with result - this is the address.

You may want to make modifications, such as the 1 in getFromLocation if you want more than one location, or with the address.getAddressLine you may want to get more than one line.

You will want to put it within a try {} block and do it in a worker thread.

Reed
  • 14,703
  • 8
  • 66
  • 110
3

Google reverse geocoding is your friend: http://code.google.com/apis/maps/documentation/geocoding/

James Butler
  • 3,852
  • 1
  • 26
  • 38