how to get the exact latlng value in android
i want to get the latlng value base on user input address for e.g. limda chowk, rajkot, gujarat, india.
but i am not getting perfect latlng value.
if i pass the street like limda chowk, subhash road, rajkot, gujarat, india, then it'll give me the latlng center of the street.
i want that particular latlng of that location how can i get this think in android
here is my code for that
public static String getLatLng(Context context,String addr){
Geocoder geocoder = new Geocoder(context, Locale.getDefault());
String add;
try{
List<Address> addresses = geocoder.getFromLocationName(addr, 1);
Address obj = addresses.get(0);
add = obj.getAddressLine(0);
add = add + "\nCountryName " + obj.getCountryName();
add = add + "\nCountryCode " + obj.getCountryCode();
add = add + "\nAdminArea " + obj.getAdminArea();
add = add + "\nPostalC开发者_如何学Code " + obj.getPostalCode();
add = add + "\nSubAdminArea " + obj.getSubAdminArea();
add = add + "\nFeatureName " + obj.getFeatureName();
add = add + "\nLocality " + obj.getLocality();
add = add + "\n" + obj.getSubThoroughfare();
add = add + "\nurl " + obj.getUrl();
add = add + "\nLatitude " + obj.getLatitude();
add = add + "\nLongitude " + obj.getLongitude();
//Log.v("IGA", "Address" + add);
}catch(Exception e){
e.printStackTrace();
add = e.toString();
}
return add;
}
thanks
Did you try Get Latitude and Logitude from Address, android
Thanks Deepak
actually I got the answer for my question that was, google not store the all the address for the area like wise here in my question "limda chowk", because it's not too famous or not important with the nearest other place like "sastriya medan". If I want to exact latlng of the place I need to create my own database, collect the addresses information and store into this database with appropriate latlng value.
精彩评论