title: Load Google Map in Fragment / swipeable Tab
body: <p>i am working with swipeable tabs and want to display a mapsfragment inside the second tab, but everytime i try to get access to the map, there appears a nullpointerexception. Following the code of my Fragment/Tab.</p>
  
  <pre><code> public class tab2_advanced extends Fragment implements OnMapReadyCallback{
      private GoogleMap gmap;
      private static View view;
      MapView ourMap;
  
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
          View v = inflater.inflate(R.layout.tab2_erweitertezusage, container, false);
  
          Log.i("TAB2", "Start.");
  
      //without the following lines regarding null or not null, the fragment loads the map, but i want to set markers and select a position on the map.
          if (gmap==null) {
              Log.i("Tab2", "Map null");
              gmap = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
              gmap.setMyLocationEnabled(true);
          }
          if (gmap != null) {
              Log.i("Tab2", "Map not null");
              gmap.setMyLocationEnabled(true);
          }
      return v;
      }
      @Override
      public void onMapReady(GoogleMap googleMap) {
          Log.i("Aufruf onMapReady", "Darstellung"+gmap);
          //Später Übergabe der Pos aus DB
          LatLng sidney= new LatLng(49.7685, 9.9382);
  
          gmap.setMyLocationEnabled(true);
          gmap.moveCamera(CameraUpdateFactory.newLatLngZoom(wuerzburg, 13));
  
          gmap.addMarker(new MarkerOptions()
                  .title("Sydney")
                  .snippet("The most populous city in Australia.")
                  .position(wuerzburg));
      }
  </code></pre>
  
  <p>My XML-File for this is the following: </p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingTop="50dp"&gt;
  
  
      &lt;LinearLayout
          android:orientation="vertical"
          android:id="@+id/layoutMap"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="200dp"
          android:name="com.google.android.gms.maps.SupportMapFragment"/&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Without the described part in comments in the code of the fragment, the map loads the content. There are still some parts missing in the case, if the map is not null, but i tried it and it lands everytime in null with a following NullpointerException.</p>
  
  <p>Hoping for hints :)</p>
  
  <p>Greetings</p>