3
public class Trees extends FragmentActivity implements GoogleMap.OnMarkerClickListener {
private GoogleMap mMap;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_trees);
setUpMapIfNeeded();
}
@Override
protected void onResume() {
super.onResume();
setUpMap();
}
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();
mMap.setMyLocationEnabled(true);
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude),17));
}
}
}
那麼這樣做有什麼問題?你有沒有嘗試過目前? – 2014-11-24 03:59:15
我已經嘗試過,實際上我正在實現帶有碎片的導航抽屜,並且沒有在地圖活動中獲取導航抽屜,因爲它是一個碎片活動。請儘快幫我解決這個問題? – user3550704 2014-11-25 00:27:26