title: Clickable Google Maps marker in Fragment
body: <p>What I am trying to accomplish here is be able to show a AlertDialog when I click on a marker that is dynamically added on load (call an API, get positions and show them on map). This is done in the fragments <code>onCreateView</code>.</p>
  
  <p>The map loads here:</p>
  
  <pre><code>@Override
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      FragmentManager fm = getChildFragmentManager();
      mapFragment = (SupportMapFragment) fm.findFragmentById(R.id.map_container);
      if (mapFragment == null) {
          mapFragment = SupportMapFragment.newInstance();
          fm.beginTransaction().replace(R.id.map_container, mapFragment).commit();
      }
  }
  </code></pre>
  
  <p>Later on, I switch from a <code>SupportMapFragment</code> to a <code>GoogleMap</code>:</p>
  
  <pre><code>@Override
  public void onResume() {
      super.onResume();
      if (mMap == null &amp;&amp; mapFragment != null) {
          mapFragment.getMapAsync(new OnMapReadyCallback() {
              @Override
              public void onMapReady(GoogleMap googleMap) {
                  mMap = Tools.configBasicGoogleMap(googleMap);
                  mMap.setMapType(sharedPref.getMapType());
              }
          });
      }
  }
  </code></pre>
  
  <p>So, logically, my Map should be ready as <code>mMap</code>. Now, I want to show a AlertDialog, so I do <code>implements GoogleMap.OnMarkerClickListener</code> in the class definition for the fragment and implement it here:</p>
  
  <pre><code>@Override
  public boolean onMarkerClick(final Marker marker) {
      Toast.makeText(getContext(), "Hello world", Toast.LENGTH_SHORT).show();
      AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
      builder.setTitle("Confirmation");
      builder.setMessage("Pour confirmer le rapport, appuyez sur + 1.\nSi le rapport est faux, cliquez sur - 1.");
      builder.setPositiveButton("+ 1", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id){
              URL link = null;
              try {
                  link = new URL(S.base_url + "report/increment/" + marker.getTag().toString());
              } catch (MalformedURLException e) {
                  e.printStackTrace();
              }
              try {
                  BufferedReader in = new BufferedReader(
                          new InputStreamReader(
                                  link.openStream()));
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      });
      AlertDialog ab = builder.create();
      ab.show();
      return false;
  }
  </code></pre>
  
  <p>But not even the Toast doesn't show up... When I click on a marker I get the Directions and Open in Google Maps buttons, and the map centers itself on the marker, but my method doesn't start.</p>
  
  <p>To conclude, logically when I click one of these markers that I load, the method onMarkerClick should trigger itself, but this never happens! Any idea why? Thanks.</p>