【发布时间】:2017-08-12 15:00:07
【问题描述】:
几年前有一个问题,如何仅使用地址获取经纬度坐标(这里是问题的链接:How can I find the latitude and longitude from address?)
我理解那里接受的答案,但我的问题是,例如,在德国你没有唯一的地址,所以如果我只使用地址来获取经纬度坐标,我可能会得到错误的经纬度坐标。就像,在柏林和法兰克福有一个地址叫做“Hauptstrasse”。所以我会得到错误的坐标。
有什么方法可以使用地址和邮政编码来获得正确的经纬度坐标吗?
例如此代码仅使用地址:
public GeoPoint getLocationFromAddress(String strAddress){
Geocoder coder = new Geocoder(this);
List<Address> address;
GeoPoint p1 = null;
try {
address = coder.getFromLocationName(strAddress,5);
if (address==null) {
return null;
}
Address location=address.get(0);
location.getLatitude();
location.getLongitude();
p1 = new GeoPoint((double) (location.getLatitude() * 1E6),
(double) (location.getLongitude() * 1E6));
return p1;
}
}
【问题讨论】:
标签: android google-maps