with Direction API you can acheive this. I don't use often this API, but you can get what you want using this :
http://maps.googleapis.com/maps/api/directions/json?origin=53.286288,-6.801891&destination=51,19&sensor=false
I put your coordinates in origin. And in the result you can see a start_address
:
start_address: "R403, Co. Kildare, Irlande",
or without putting a destination :
http://maps.googleapis.com/maps/api/geocode/json?latlng=53.286288,-6.801891&sensor=false
formatted_address: "R403, Co. Kildare, Irlande",
EDIT : To call & retrieve the Json
Don't forget to ask Internet permission in the manifest
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
here a method to get what you want with the lat & lng params. Don't forget to call this in a background thread. (You can do it easily with an AsyncTask).
private void getRoadName(String lat, String lng) {
String roadName = "";
String url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=__LAT__,__LNG__&sensor=false";
url = url.replaceAll("__LAT__", lat);
url = url.replaceAll("__LNG__", lng);
DefaultHttpClient httpclient = new DefaultHttpClient(new BasicHttpParams());
HttpGet httpget = new HttpGet(url);
InputStream inputStream = null;
String result = null;
try {
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
inputStream = entity.getContent();
// json is UTF-8 by default
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
result = sb.toString();
} catch (Exception e) {
// Oops
}
finally {
try{if(inputStream != null)inputStream.close();}catch(Exception squish){}
}
JSONObject jObject = new JSONObject(result);
JSONArray jArray = jObject.getJSONArray("results");
if (jArray != null && jArray.size > 0) {
try {
JSONObject oneObject = jArray.getJSONObject(i);
// Pulling items from the array
roadName = oneObject.getString("formatted_address");
} catch (JSONException e) {
// Oops
}
}
}
code to parse JSON from : How to parse JSON in Android
blocks, 4 space indents, console character, highlight and ctrl-k. dont know man sorry?
– user2269886 Jan 08 '14 at 17:58