Convert Latitude,Longitude to Address Using Android,Php

We get location and latitude using LocationManager Class in android. We can get address using that also.

Android Code——————————————————————————————-
private String getName(String lat,String lng) throws IOException
String add=””;
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
               List addresses = geocoder.getFromLocation(lat, lng, 1);

Address obj = addresses.get(0);
             add = obj.getAddressLine(0) +” “+obj.getAddressLine(1)+” ”                                                          + obj.getAddressLine(2);
catch(Exception ex)
return add;


Php Code

Also Using Php , we can get address from longitude,latitude.




$init = curl_init();

curl_setopt($init, CURLOPT_URL, $url);
curl_setopt($init, CURLOPT_HEADER,0);
curl_setopt($init, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($init);

echo $response;



(Json Format)


(XML Format)

In Url you can specify whether you want output in json or xml. Once you get output, you need to extract the address using the string operations.


Leave a Reply

Your email address will not be published. Required fields are marked *