public GeoPoint getGeoPointBystr(String str) {//GeoPoint来自谷歌
GeoPoint gpGeoPoint = null;
if (str!=null) {
Geocoder gc = new Geocoder(Demo2Activity.this,Locale.CHINA);
List<Address> addressList = null;
try {
addressList = gc.getFromLocationName(str, 1);
Log.i("tag","addressList=="+addressList.size());
if (!addressList.isEmpty()) {
Address address_temp = addressList.get(0);
//计算经纬度
double Latitude=address_temp.getLatitude()*1E6;
double Longitude=address_temp.getLongitude()*1E6;
System.out.println("经度:"+Latitude);
System.out.println("纬度:"+Longitude);
//生产GeoPoint
gpGeoPoint = new GeoPoint((int)Longitude, (int)Latitude);
}
else{
Log.i("tag","Demo2Activity:else");
}
} catch (IOException e) {
e.printStackTrace();
}
}
return gpGeoPoint;
}
GeoPoint gpGeoPoint = null;
if (str!=null) {
Geocoder gc = new Geocoder(Demo2Activity.this,Locale.CHINA);
List<Address> addressList = null;
try {
addressList = gc.getFromLocationName(str, 1);
Log.i("tag","addressList=="+addressList.size());
if (!addressList.isEmpty()) {
Address address_temp = addressList.get(0);
//计算经纬度
double Latitude=address_temp.getLatitude()*1E6;
double Longitude=address_temp.getLongitude()*1E6;
System.out.println("经度:"+Latitude);
System.out.println("纬度:"+Longitude);
//生产GeoPoint
gpGeoPoint = new GeoPoint((int)Longitude, (int)Latitude);
}
else{
Log.i("tag","Demo2Activity:else");
}
} catch (IOException e) {
e.printStackTrace();
}
}
return gpGeoPoint;
}