【发布时间】:2011-04-05 17:29:06
【问题描述】:
在 android 中使用 MapView,如何设置默认位置,以便每次加载此应用程序时,它会自动将位置居中/缩放到伦敦?
【问题讨论】:
标签: android android-mapview android-2.2-froyo
在 android 中使用 MapView,如何设置默认位置,以便每次加载此应用程序时,它会自动将位置居中/缩放到伦敦?
【问题讨论】:
标签: android android-mapview android-2.2-froyo
首先,获取给定地图的控制器:
MapController myMapController = myMapView.getController();
然后调用:
myMapController.setCenter(new GeoPoint())
这会将地图的中心设置在给定的 GeoPoint 上。
有关更多信息,请参阅 MapView 和 MapController 的文档
【讨论】:
对于新的 Google Maps API,您需要这样做:
mapFragment.getMapAsync(this::setUpMaps);
在setUpMaps(GoogleMap googleMap) 内,您应该将相机移动到默认位置:
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, zoom));
【讨论】: