我想实现 Google maps v2 和 jfeinstein10 的 SliderMenu,我设法实现了 SliderMenu 但是当我想在活动中添加地图时,我得到了错误
GoogleMap 地图 = ((SupportMapFragment) getSupportFragmentManager (). FindFragmentById (R.id.fragMapa))。获取地图();
在 getSupportFragmentManager () 中更具体
任何集成两者的解决方案。我把活动的代码。
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity;
public class ActivityPrincipal extends SlidingActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity_principal);
GoogleMap mapa = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.fragMapa)).getMap();
LatLng coordenadasGT = new LatLng(15.45368,-90.485115);
CameraPosition camPos = new CameraPosition.Builder()
.target(coordenadasGT)
.zoom(8)
.build();
CameraUpdate camUpd = CameraUpdateFactory.newCameraPosition(camPos);
mapa.moveCamera(camUpd);
}
/*
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_principal, menu);
return true;
}
*/
}