摘要:Android - 使用Address 查坐標位置
/**
* 使用地址查詢經緯度坐標 回傳 Location
* @param context
* @param address
* @return
*/
public static LatLng getLocationByAddress(Context context,String address){
LatLng latlng = null ;
Geocoder mGeocoder01 = new Geocoder(context,Locale.getDefault());
try {
List listAddress = mGeocoder01.getFromLocationName(address, 70 ) ;
if(!listAddress.isEmpty()){
Address adsLocation = listAddress.get(0);
double lat = adsLocation.getLatitude() ;
double lon = adsLocation.getLongitude() ;
latlng = new LatLng(lat,lon);
}
} catch (IOException e) {
e.printStackTrace();
}
return latlng;
}