HERE Maps Android SDK 中 GeocodeRequest 的正确查询结构?
Proper query structure for GeocodeRequest in HERE Maps Android SDK?
自 HERE Maps Android SDK 版本 3.0 起,GeocodeRequest 采用自由文本查询来执行地理编码请求过程,但不清楚是什么传递查询的正确结构。 "country city" 或 "country, city" 或 "city country"... 等等
在我的实现中,用户选择 country/city 并基于此我想通过执行地理编码请求以从该位置获取地理坐标来将地图置于该 country/city 的中心,所以问题是我应该如何形成查询,以便地理编码在其 onComplete 方法中请求 returns 位置,以及准确的半径值是多少?
我目前的实现如下
String geoCodeQuery = String.format("%s %s",
selectedDestinationCity == null ? "" : selectedDestinationCity.getCity(),
selectedDestinationCountry == null ? "" : selectedDestinationCountry.getCountry());
GeocodeRequest geocodeRequest = new GeocodeRequest(geoCodeQuery);
geocodeRequest.setSearchArea(new GeoCoordinate(
selectedDestinationCountry.getCapitalCityCoordinate().getLatitude(),
selectedDestinationCountry.getCapitalCityCoordinate().getLongitude()), 5000);
geocodeRequest.execute(new ResultListener<List<Location>>() {
@Override
public void onCompleted(List<Location> locations, ErrorCode errorCode) {
loadingDialog.dismiss();
if (errorCode == ErrorCode.NONE) {
if (locations.size() > 0) {
GeoCoordinate location = locations.get(0).getCoordinate();
addressModelBuilder.setLatitude(location.getLatitude());
addressModelBuilder.setLongitude(location.getLongitude());
}
}
}
});
感谢您的帮助。
标准格式的地址就足够了(例如城市、州、国家/地区)。如果 Geocoder 没有返回预期的结果,那么您可能遇到了一个已知的 Geocoder 错误...请尝试对 setSearchArea() 使用较小的半径(例如 1m)。
但是,如果 GeoCodeRequest 未产生任何结果,则可以使用的替代请求是 TextAutoSuggestionRequest 或 SearchRequest。
仅在线查询中的 TextAutoSuggestionRequest。
SearchRequest 适用于两个 online/offline 查询。
这些查询可能用于 https://wego.here.com 处的单一框查询。
自 HERE Maps Android SDK 版本 3.0 起,GeocodeRequest 采用自由文本查询来执行地理编码请求过程,但不清楚是什么传递查询的正确结构。 "country city" 或 "country, city" 或 "city country"... 等等
在我的实现中,用户选择 country/city 并基于此我想通过执行地理编码请求以从该位置获取地理坐标来将地图置于该 country/city 的中心,所以问题是我应该如何形成查询,以便地理编码在其 onComplete 方法中请求 returns 位置,以及准确的半径值是多少?
我目前的实现如下
String geoCodeQuery = String.format("%s %s",
selectedDestinationCity == null ? "" : selectedDestinationCity.getCity(),
selectedDestinationCountry == null ? "" : selectedDestinationCountry.getCountry());
GeocodeRequest geocodeRequest = new GeocodeRequest(geoCodeQuery);
geocodeRequest.setSearchArea(new GeoCoordinate(
selectedDestinationCountry.getCapitalCityCoordinate().getLatitude(),
selectedDestinationCountry.getCapitalCityCoordinate().getLongitude()), 5000);
geocodeRequest.execute(new ResultListener<List<Location>>() {
@Override
public void onCompleted(List<Location> locations, ErrorCode errorCode) {
loadingDialog.dismiss();
if (errorCode == ErrorCode.NONE) {
if (locations.size() > 0) {
GeoCoordinate location = locations.get(0).getCoordinate();
addressModelBuilder.setLatitude(location.getLatitude());
addressModelBuilder.setLongitude(location.getLongitude());
}
}
}
});
感谢您的帮助。
标准格式的地址就足够了(例如城市、州、国家/地区)。如果 Geocoder 没有返回预期的结果,那么您可能遇到了一个已知的 Geocoder 错误...请尝试对 setSearchArea() 使用较小的半径(例如 1m)。
但是,如果 GeoCodeRequest 未产生任何结果,则可以使用的替代请求是 TextAutoSuggestionRequest 或 SearchRequest。
仅在线查询中的 TextAutoSuggestionRequest。
SearchRequest 适用于两个 online/offline 查询。
这些查询可能用于 https://wego.here.com 处的单一框查询。