版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhuxingchong/article/details/82627312
这是通过google原生接口获取的经纬度
public static Address getGeoPointBystr(Context context,String str) {
Address address_temp = null;
if (str != null) {
Geocoder gc = new Geocoder(context, Locale.CHINA);
List<Address> addressList = null;
try {
addressList = gc.getFromLocationName(str, 1);
if (!addressList.isEmpty()) {
address_temp = addressList.get(0);
double Latitude = address_temp.getLatitude();
double Longitude = address_temp.getLongitude();
Log.d("zxc003",str+" Latitude = "+Latitude+" Longitude = "+Longitude);
}
} catch (IOException e) {
e.printStackTrace();
}
}
return address_temp;
}