我正在使用 Android 的地理编码器来允许在我的基于地图的应用程序中搜索位置。地理编码运行良好,应用程序成功地将 MapView 重新定位在地理编码结果上。问题是我不知道移动到新位置时要使用什么缩放级别。参数可以是一条街道,location_query
也可以是一个国家——我怎么知道放大多远才能显示结果位置?也就是说,我用什么代替???
?
public void goToPlace(String location_query) {
List<Address> addresses;
Geocoder gc = new Geocoder(_ctx);
addresses = gc.getFromLocationName(location_query, 1);
if (addresses != null) {
Address a = addresses.get(0);
int lat = (int) (a.getLatitude() * 1E6);
int lon = (int) (a.getLongitude() * 1E6);
mapController.animateTo(new GeoPoint(lat, lon));
mapController.setZoom(???);
}
}