title: Android Google Maps V2 - OnInfoWindowClick on several markers
body: <p>I have the code to make one marker start a activity when you click on the infowindow. It works absolutely fine. But when I try to add in another marker and another @override it always opens the last class on all of the Markers infowindows. So in essence all of the markers infowindows open the same activity when clicked instead of opening the separate class that I intended it to. </p>
  
  <p><strong>This is the code below that successfully opens 1 activity on InfoWindowClicked. I have called it example.class, <em>this is for everyone that needs this example</em>.</strong></p>
  
  <pre><code> public class MainActivity extends Activity implements OnInfoWindowClickListener {
  
   private GoogleMap googlemap;
  
  
   @Override
   protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
  
  if(isGooglePlay()){
  setContentView(R.layout.activity_main);
  setUpMap();
  
  {    }    }
  
  
  googlemap.addMarker(new MarkerOptions()
  .position(new LatLng(0,-0))
  .title("Title")
  .snippet("Snippet")    
  .icon(BitmapDescriptorFactory.fromResource(R.drawable.star)));
  googlemap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
  
  @Override
  public void onInfoWindowClick(Marker marker) {
   Intent intent = new Intent(MainActivity.this,Example.class);
   startActivity(intent);
            } });
  {
  </code></pre>
  
  <p>So underneath <strong>GoogleMap googlemap/mMap</strong> (or whatever you call yours) and the <strong>@override void Oncreate</strong> (my application only starts if GooglePlayServices is available, yours might not be like this) you can put the marker and infowindowclick code. </p>
  
  <p>Make sure somewhere in the code there is aswell (usually in a private void setUpMap(){ ) </p>
  
  <pre><code>    googlemap = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
  </code></pre>
  
  <p><strong>Now below is the code with two markers but both of them open the example2.class when they are clicked. Can someone help me figure this out so I can separate them and have them open different classes?</strong></p>
  
  <pre><code> googlemap.addMarker(new MarkerOptions()
  .position(new LatLng(0,-0))
  .title("Title")
  .snippet("Snippet")    
  .icon(BitmapDescriptorFactory.fromResource(R.drawable.star)));
  googlemap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
  
  @Override
  public void onInfoWindowClick(Marker marker) {
   Intent intent = new Intent(MainActivity.this,Example.class);
   startActivity(intent);
            } });
  {
  
        {
  googlemap.addMarker(new MarkerOptions()
  .position(new LatLng(  0, -0))
  .title("Title")
  .snippet("Snippet")
  .icon(BitmapDescriptorFactory.fromResource(R.drawable.star)));
  googlemap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
  
  
  @Override
  public void onInfoWindowClick(Marker marker) {
  Intent intent = new Intent(MainActivity.this,Example2.class);
  startActivity(intent);
          }  });
  }}
  
  
  }
  </code></pre>
  
  <p><em><strong>Edit (07/06/2013):</em></strong></p>
  
  <pre><code>private GoogleMap googlemap; 
  private Map&lt;Marker, Class&gt; allMarkersMap = new HashMap&lt;Marker, Class&gt;();
  </code></pre>
  
  <p>The above is on the class level^^^</p>
  
  <pre><code> Marker marker1 = googlemap.addMarker(new MarkerOptions()
  .position(new LatLng(0,0))
  .title("England")
  .snippet("London")    
  .icon(BitmapDescriptorFactory.fromResource(R.drawable.star)));
  allMarkersMap.put(marker1, Contact.class);
  
  }
  
  public void onInfoWindowClick(Marker marker) {
  Class cls = allMarkersMap.get(marker);
  Intent intent = new Intent(MainActivity.this, cls);
  startActivity(intent);
  
  }
  </code></pre>
  
  <p>The above ^^^^ is under my "protected void onCreate(Bundle savedInstanceState) {". There are no errors, when I debug I can see the Marker but cannot click on the InfoWindow. The warnings are:</p>
  
  <pre><code>Class is a raw type. References to generic type Class&lt;T&gt; should be parameterized    
  </code></pre>
  
  <p>I see this warning twice on the class level and once in the public void onInfoWindowClick on the word <strong><em>'Class'</em></strong>. I've tried a few different things like "Add type arguments to 'Class' but it didn't work. On <strong>Marker marker</strong> in the public void I changed <strong>marker</strong> to <strong>marker1</strong> and on the line below <strong>allMarkersMap.get(marker);</strong> changed <strong>(marker)</strong> to <strong>(marker1)</strong>  just to try but it didn't work. Is there anything else I can do to try and initialize the onInfoWindowClick function?</p>