title: How to use google Map Api2 along-with-other-fragments-in-an-app
body: <p>Am trying to create and app with one activity but multiple fragment. i am using android.support.v4.* to build the fragment.
  Each item i have created so far by extending Fragment, I want to use the google Map Api2 in my application, </p>
  
  <p>All the tutoril i found so far adding the "SupportMapFragment" as an element to layout  file.</p>
  
  <pre><code>"&lt;fragment
      class="com.google.android.gms.maps.SupportMapFragment"
      android:layout_width="match_parent"
      android:layout_height="match_parent"/&gt;"
  </code></pre>
  
  <p>But i cannot use this way because nested fragment not supporting, how can i use the google map api2 as a fragment in my application</p>
  
  <p>use the mapview as suggested in Comments</p>
  
  <pre><code> public class InteractiveMapsWidget extends Fragment {
          private MapView mMapView;
          private GoogleMap mMap;
  
       public void onCreate(Bundle savedInstanceState) {
              super.onActivityCreated(savedInstanceState);
              Log.i(TAG, "ON CREATED");
              Activity activity = getActivity();
              if (activity != null) {
                  Bundle bundle = getArguments();
      `
              }
          }
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)     {
              Log.i(TAG, "onCreateView");
              new DataWorkerAsyncTask(getActivity()).execute(widgetId);
              mMapView = (MapView) view.findViewById(R.id.map);
              mMapView.onCreate(savedInstanceState);
              setUpMapIfNeeded();
  
              return view;
          }
  
  
          @Override
          public void onResume() {
              super.onResume();
              mMapView.onResume();
  
              setUpMapIfNeeded();
          }
  
          private void setUpMapIfNeeded() {
              if (mMap == null) {
                  mMap = ((MapView) view.findViewById(R.id.map)).getMap();
                  if (mMap != null) {
                      setUpMap();
                  }
              }
          }
  
          private void setUpMap() {
              mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
          }
  
          @Override
          public void onPause() {
              mMapView.onPause();
              super.onPause();
          }
  
          @Override
          public void onDestroy() {
              mMapView.onDestroy();
              super.onDestroy();
          }
  
          @Override
          public void onLowMemory() {
              super.onLowMemory();
              mMapView.onLowMemory();
          }
  
          @Override
          public void onSaveInstanceState(Bundle outState) {
              super.onSaveInstanceState(outState);
          }
      }
  </code></pre>
  
  <p>Layout </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:map="http://schemas.android.com/apk/res-auto"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
    &lt;LinearLayout
          android:id="@+id/root_container"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical" &gt;
          &lt;com.google.android.gms.maps.MapView
              xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/map"
              android:layout_width="match_parent"
              android:layout_height="match_parent" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>