Android GeoCoder getFromLocation地址从不包含企业名称
我正在尝试对从标记检索到的LatLng进行反向地理编码,以获取地址。我很容易获得街道地址,但getFromLocation()返回的地址从不包含企业名称(例如Tim Hortons)。我知道问题不在于坐标,因为当我在代码的不同部分使用“getFromLocationName()”返回相同的结果时,我得到的是友好的名称。我看不出getFromLocation()的返回值与getFromLocationName()的返回值有什么不同 以下是相关代码:Android GeoCoder getFromLocation地址从不包含企业名称,android,google-maps,geolocation,location,street-address,Android,Google Maps,Geolocation,Location,Street Address,我正在尝试对从标记检索到的LatLng进行反向地理编码,以获取地址。我很容易获得街道地址,但getFromLocation()返回的地址从不包含企业名称(例如Tim Hortons)。我知道问题不在于坐标,因为当我在代码的不同部分使用“getFromLocationName()”返回相同的结果时,我得到的是友好的名称。我看不出getFromLocation()的返回值与getFromLocationName()的返回值有什么不同 以下是相关代码: private String holderAdd
private String holderAddress;
...
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
getAddress(marker.getPosition());
...
private void getAddress(LatLng latLng){
Geocoder reverseGeo = new Geocoder(this, Locale.getDefault());
Address processAddress = null;
try {
processAddress = reverseGeo.getFromLocation(latLng.latitude,
latLng.longitude, 1).get(0);
}catch(Exception e){
Log.v("Reverse Geocode failed", e.getMessage());
}
if (processAddress != null) {
holderAddress = processAddress.getAddressLine(0);
} else {
holderAddress = "(" + latLng.latitude + "," + latLng.longitude + ")";
}
}
我尝试检索多个结果并读取所有地址行以及功能名称。“getFromLocation()”似乎从不返回业务名称,而“getFromLocationName()”总是设法获取友好名称
任何关于我为什么会得到这个结果的见解,或者对可能的解决方法的建议,都将不胜感激
谢谢。我已经得出结论,地理编码对于实时地点查找是不可行的。虽然有一个getFeatureName()字段,但它似乎只返回对精确GPS坐标有用的任何内容,因此删除pin几乎永远不会产生有用的fetaure名称
我已经切换到Google Places API来查找企业名称,并且为了一致性,我现在也使用nearbysearch from Places API来搜索,而不是地理编码。getFromLocation()的输入是纬度和经度,而
getFromLocationName()的输入是地址名。所以结果是不同的。