title: How do I add same event listener to many markers and then differentiate between the markers in the listeners in Google Maps API v3?
body: <p>I have the same event listener for many markers in my Javascript. How do I differentiate between different markers in this listener? I want to display another marker elsewhere on clicking of a particular marker. Every marker has another marker which I display on clicking on it.</p>
  
  <p>The event listener code:</p>
  
  <pre><code>google.maps.event.addListener(marker, 'click', function() {
  //code goes here
  
  });
  </code></pre>
  
  <p>More detail:</p>
  
  <p>I have two arrays <code>markers1</code> and <code>markers2</code> each having 10 markers. I display the 10  from <code>markers1</code> on my map. On clicking <code>markers1[0]</code> marker I want to display the <code>markers2[0]</code> marker on the map. How do I know in the event listener that I have clicked on <code>markers1[0]</code>, now I know that I can use the <code>THIS</code> for identifying <code>markers1[0]</code> but how do I know in the listener that it was the marker at the position 0 in array <code>markers1</code> so that I could also display marker at position 0 in array <code>markers2</code>?</p>