public double[] getGeoCodesFromAddress(String pLocationAddress) {
try {
cLocationGeneratorProp = new LocationGeneratorProp();
objGeoCoder = new Geocoder(vContext, Locale.getDefault());
vListAddress = objGeoCoder.getFromLocationName(pLocationAddress, 1);
if (vListAddress != null) {
latlong = new double[2];
latlong[0] = vListAddress.get(0).getLatitude();
latlong[1] = vListAddress.get(0).getLongitude();
}
} catch (Exception e) {
Log.e("getGeoCodesFromAddress()", e.getMessage().toString());
}
return latlong;
}
LocationGeneratorProp
public class LocationGeneratorProp {
private String postalcode;
private String countryname;
private String countrycode;
private String fulladdress;
private String locationtype;
private double locationLat;
private double locationLong;
private double fromlocationlatitude;
private double fromlocationlongitude;
private double destinationlocationlatitude;
private double destinationlocationlongitude;
public String getPostalcode() {
return postalcode;
}
/**
* @param postalcode
* Postal Code Of the Adrress
*/
public void setPostalcode(String postalcode) {
this.postalcode = postalcode;
}
/**
* @return String CountryName
*
*/
public String getCountryname() {
return countryname;
}
public void setCountryname(String countryname) {
this.countryname = countryname;
}
public String getCountrycode() {
return countrycode;
}
public void setCountrycode(String countrycode) {
this.countrycode = countrycode;
}
public String getFulladdress() {
return fulladdress;
}
public void setFulladdress(String fulladdress) {
this.fulladdress = fulladdress;
}
public String getLocationtype() {
return locationtype;
}
public void setLocationtype(String locationtype) {
this.locationtype = locationtype;
}
public double getLocationLat() {
return locationLat;
}
public void setLocationLat(double locationLat) {
this.locationLat = locationLat;
}
public double getLocationLong() {
return locationLong;
}
public void setLocationLong(double locationLong) {
this.locationLong = locationLong;
}
public double getFromlocationlatitude() {
return fromlocationlatitude;
}
public void setFromlocationlatitude(double fromlocationlatitude) {
this.fromlocationlatitude = fromlocationlatitude;
}
public double getFromlocationlongitude() {
return fromlocationlongitude;
}
public void setFromlocationlongitude(double fromlocationlongitude) {
this.fromlocationlongitude = fromlocationlongitude;
}
public double getDestinationlocationlatitude() {
return destinationlocationlatitude;
}
public void setDestinationlocationlatitude(
double destinationlocationlatitude) {
this.destinationlocationlatitude = destinationlocationlatitude;
}
public double getDestinationlocationlongitude() {
return destinationlocationlongitude;
}
public void setDestinationlocationlongitude(
double destinationlocationlongitude) {
this.destinationlocationlongitude = destinationlocationlongitude;
}
}
jst用给定的地址测试了代码工作fne让我知道是否有任何问题..with ths