I have a question about the google api function called getFromLocationName()
I use the following code to put the address where I want to get the coordinates.
Geocoder geoCoder = new Geocoder(test.this, Locale.TAIWAN);
float add_lat=0,add_lot=0;
try {
List addresses = geoCoder.getFromLocationName(location,1);
if (!addresses.isEmpty()) {
add_lat=(float) (addresses.get(0).getLatitude()*1E6);
add_lot=(float) (addresses.get(0).getLongitude()*1E6);
}
} catch (IOException e) {
e.printStackTrace();
}
When I printed the values of coordinates,I always got zero point zero.
I don’t know how to solve this problem,because it didn’t get any error message when I compiled my code.
Please give me your point of views
Thanks 🙂
I would suggest you should first check the presence of GeoCoder implementation and only then use it. It is not necessarily present in all devices.