2013-09-29 63 views
0

我想要實現谷歌地圖v2和jfeinstein10的SliderMenu,我設法實現SliderMenu但當我想添加地圖活動中,我得到錯誤谷歌地圖整合和SlidingMenu

GoogleMap的地圖=(( SupportMapFragment)getSupportFragmentManager()。FindFragmentById(R.id.fragMapa))。 GetMap();

是在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; 
    } 
    */ 

} 
+0

你還沒有實際提供有關錯誤你」的任何信息重新獲得。 – Trevor

回答

1

我設法整合了jfeinstein10的Google maps v2和SliderMenu。 我的動態擴展ActionBarActivity,我使用滑塊菜單通過編程方式構建它:

public void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 

      setContentView(R.layout.main); 

      SlidingMenu menu = new SlidingMenu(this); 
      menu.setMode(SlidingMenu.LEFT_OF); 
      menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); 
      menu.setFadeDegree(0.35f); 
      menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW); 
      menu.setMenu(R.layout.options); 
      menu.setShadowDrawable(R.drawable.shadow); 
      menu.setShadowWidthRes(R.dimen.shadow_width); 
      menu.setBehindOffsetRes(R.dimen.slidingmenu_offset); 
      menu.setFadeDegree(0.35f); 
      menu.setOnOpenedListener(this); 

      FragmentManager fmanager = getSupportFragmentManager(); 
      Fragment fragment = fmanager.findFragmentById(R.id.mapView); 
      SupportMapFragment supportmapfragment = (SupportMapFragment) fragment; 

      mMap = supportmapfragment.getMap(); 
      mMap.getUiSettings().setZoomControlsEnabled(false); 
      mMap.setOnMapClickListener(this); 
      mMap.setOnInfoWindowClickListener(this); 
      mMap.setOnMarkerClickListener(this); 
      mMap.setMyLocationEnabled(true); 
      mMap.setOnMyLocationChangeListener(this); 
      mMap.setOnMyLocationButtonClickListener(this); 
    } 

MapView的是我的佈局片段:

<fragment 
      android:id="@+id/mapView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      class="com.google.android.gms.maps.SupportMapFragment" />