我有一个SherlockFragmentActivity
显示GoogleMap使用Google Maps Android API v2。我希望地图在片段启动后立即放大到当前位置。在documentation中我找不到这样的方法。如何实现这一目标?将谷歌地图放大到我的位置
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ui_settings_demo);
setUpMapIfNeeded();
}
@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map))
.getMap();
if (mMap != null) {
setUpMap();
}
}
}
private void setUpMap() {
mMap.setMyLocationEnabled(true);
//How to zoom to my current location?
}
是否有窍门。谢谢! – iTurki 2013-05-04 19:26:51