我有一个地址,我想知道坐标。例如,地址是纽约州皇后区的“Skillman Ave”。根据maps.google.com,坐标为:40.747281, -73.9283169
。在我的应用程序,我有这样的功能:地理编码android - 经度和纬度值不正确
public GeoPoint addressToGeo(String adr) {
Geocoder coder = new Geocoder(this);
List<Address> address = null;
GeoPoint coordinates;
try {
address = coder.getFromLocationName(adr, 1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (address == null) {
return null;
}
Address location = address.get(0);
location.getLatitude();
location.getLongitude();
coordinates = new GeoPoint((int) (location.getLatitude() *1E6),
(int) (location.getLongitude() * 1E6));
return coordinates;
}
这需要一个地址作为参数,并希望它会返回坐标。我说,调试器列表中ADRESS的第一个元素包含以下信息:
[Address[addressLines=[0:"Skillman Ave",1:"Queens, New York",2:"Amerikas forente stater"],feature=Skillman Ave,admin=New York,sub-admin=Queens,locality=Queens,thoroughfare=Skillman Ave,postalCode=null,countryCode=US,countryName=Amerikas forente stater,hasLatitude=true,latitude=40.747281,hasLongitude=true,longitude=-73.9283169,phone=null,url=null,extras=null]]
如果你看的经度和纬度的变量,这似乎是正确的。但是,当我在此代码键入:
GeoPoint test;
test = addressToGeo("Skillman Ave");
double latitude = test.getLatitudeE6();
double longitude = test.getLongitudeE6();
String lat = Double.toString(latitude);
String lng = Double.toString(longitude);
String total = lat + " " + lng;
toAdress.setText(total);
的toAdress文本框将包含4.0747281E7, -7.3928316E7
逗号是不是在正确的位置,什么是每个双末端的E7
?