Skip to content Skip to sidebar Skip to footer

Obtain The Latitude And Longitude Using The Pincode On Google Maps

I have a requirement to loading a Google map location given the pin code or area code. I've tried using the Geocoder method to find the latitude and longitude using a given address

Solution 1:

For India it will not work by Pincode.

But try this alternate method. you can add additional arguments, such as "Near=", perhaps you can add Indian states to the query and make it work.

This may work but i am not sure. Have fun

Solution 2:

It works when you increase the number of location in method signature.

getFromLocationName("karnataka",
                        5);

it will give you latitude and longitude. Ex: -

publicvoidfindLocationName()
        {
     try {
    Geocoder gcd = new Geocoder(this, Locale.getDefault());
    List<Address> addresses;

    addresses = gcd.getFromLocationName("110002",5);


    for(int i=0;i<addresses.size();i++){
    Log.e("","in loop");
    Log.e("","lat :,,,,,,,,,,,,,"+addresses.get(i).getLatitude()+"  long............"+addresses.get(i).getLongitude());     
Toast.makeText(this, "lat : "+addresses.get(i).getLatitude(),1).show();
 Toast.makeText(this, "long : "+addresses.get(i).getLongitude(),1).show();
  }

     }
  catch (IOException e) {e.printStackTrace();}
    }

Post a Comment for "Obtain The Latitude And Longitude Using The Pincode On Google Maps"