title: Getting a map marker ID in Google Maps v2
body: <p>I'm getting my marker datas from my SQLite database. And I stored this datas in array list. </p>
  
  <p>In my activity, I also create route between 2 markes. (One of those markers it's user's current location) And user click random marker, it's shows the route between this marker and user's current location.
  But I have problem. Cause I don't know how do I know which marker has been clicked? Any idea?</p>
  
  <p>Note: I'm using this work for routing
  <a href="https://github.com/akexorcist/Android-GoogleDirectionLibrary" rel="nofollow noreferrer">https://github.com/akexorcist/Android-GoogleDirectionLibrary</a></p>
  
  <p>My database<a href="https://i.stack.imgur.com/ayWjI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ayWjI.png" alt="screenshot"></a></p>
  
  <p><strong>MapsActivity.java</strong></p>
  
  <pre><code>SQLiteDatabase db=dbHelper.getReadableDatabase();
          String[] getColumnName={"bakim_enlem,bakim_boylam,bakim_title"};
          Cursor imlec=db.query("bakim_yerleri", getColumnName, null, null, null, null, null);
  
          while(imlec.moveToNext())
          {
              mMap.addMarker(new MarkerOptions().position(new LatLng
                      (imlec.getDouble(imlec.getColumnIndex("bakim_enlem")),imlec.getDouble(imlec.getColumnIndex("bakim_boylam"))))
                      .title(imlec.getString(imlec.getColumnIndex("bakim_title"))).
                      icon(BitmapDescriptorFactory.fromResource(R.drawable.mapmarker)));
  
          }
  
  
          }
  
  
  
    //route code
  @Override
  public boolean onMarkerClick(final Marker marker)
  {
     //in default, you can write here and down there-&gt; LatLng marker1
     if (marker.equals(**?**))
      {
          CoordinatorLayout rootLayout = (CoordinatorLayout) findViewById(R.id.mapCoordinatorLayout);
          Snackbar.make(rootLayout, "Rota oluşturuluyor...", Snackbar.LENGTH_LONG).show();
          GoogleDirection.withServerKey(serverKey)
                  .from(suanKonumumuz)
                  .to(**?**)
                  .transportMode(TransportMode.DRIVING)
                  .execute(this);
      }
      return true;
  }
  </code></pre>