Here below is the code for searching places by using place name.
I use api provides by google also know as google place api.
"http://maps.googleapis.com/maps/api/geocode/json?address="+CITY_NAME+"&sensor=true";
In response of it We get a json having Latlng of the place and We can show these Latlng on Map.
To get Json , you can use these line after get response
String url ="http://maps.googleapis.com/maps/api/geocode/json?address="+CITY_NAME+"&sensor=true";
String response = WebServiceConnection.GetData(url);
try{
jsonObject =new JSONObject(response);
if(jsonObject.getJSONArray("results").length()>0){
}
JSONArray resultArray = jsonObject.getJSONArray("results");
JSONObject resultJsonObject = resultArray.getJSONObject(0);
String lat = resultJsonObject.getJSONObject("geometry").getJSONObject("location").getString("lat");
String lng = resultJsonObject.getJSONObject("geometry").getJSONObject("location").getString("lng");
return true;
}
catch(JSONException e)
{
e.printStackTrace();
return false;
}
0 Comment(s)