I want to show the location of an address in Google Maps.
How do I get the latitude and longitude of an address using the Google Maps API?
The following code will work for google apiv2:
public void convertAddress() {
if (address != null && !address.isEmpty()) {
try {
List addressList = geoCoder.getFromLocationName(address, 1);
if (addressList != null && addressList.size() > 0) {
double lat = addressList.get(0).getLatitude();
double lng = addressList.get(0).getLongitude();
}
} catch (Exception e) {
e.printStackTrace();
} // end catch
} // end if
} // end convertAddress
Where address is the String (123 Testing Rd City State zip) you want to convert to LatLng.