Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Search location by using place on google map

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.91k
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: