我有一個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