【发布时间】:2014-09-03 15:54:09
【问题描述】:
我想要一个示例代码,它可以让我们定位车牌,就像导航系统一样,按我们输入的名称搜索。从我们现在的位置到我们设定的目的地的位置。
【问题讨论】:
标签: android
我想要一个示例代码,它可以让我们定位车牌,就像导航系统一样,按我们输入的名称搜索。从我们现在的位置到我们设定的目的地的位置。
【问题讨论】:
标签: android
使用这个方法
/**
* Get list of address by latitude and longitude
* @return null or List<Address>
*/
public List<Address> getGeocoderAddress(Context context)
{
if (location != null)
{
Geocoder geocoder = new Geocoder(context, Locale.ENGLISH);
try
{
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
return addresses;
}
catch (IOException e)
{
//e.printStackTrace();
Log.e("Error : Geocoder", "Impossible to connect to Geocoder", e);
}
}
return null;
}
问候 行家
【讨论】:
您可以使用以下方法-
public String getLatLonByAddress(String addr) {
Geocoder geoCoder = new Geocoder(this);
List<Address> address = null;
try {
address = geoCoder.getFromLocationName(addr, 5);
}
catch (IOException e) {
e.printStackTrace();
}
if (address == null) {
return null;
}
Address location = address.get(0);
return location.getLatitude() + " / " + location.getLongitude();
}
【讨论】: