title: Show Polyline after marker click event when dealing with multiple markers.
body: <p>I am working on a web application that uses Google Maps API v3. I am creating ~ 400 markers in an hour, which are being pushed in currentlyDisplayedMarkers[]. For each marker, I am creating a Polyline containing its past locations. This works ok. However, I want to show the Polyline for a marker only when that specific marker is clicked. I created a function, called addClickHandler in which I define the onClick listener for each marker. When the marker is clicked, the Polyline should be added to the map.</p>
  
  <p>When I click the marker the Polyline is not shown on the map. 
  Do you have any ideas about what I am doing wrong?  </p>
  
  <pre><code>    if (!found)
                     {
                         var LatLng = { lat: data[i].Plots[0].Latitude, lng: data[i].Plots[0].Longitude };
                         createMarker(LatLng, 90, data[i].TrackNumber);
                         drawPolyline(data[i].Plots);
                     }
  function createMarker(markerLatLng, direction, id) {
  var iconImage = {
      path: 'M265.54,0H13.259C5.939,0,0.003,5.936,0.003,13.256v252.287c0,7.32,5.936,13.256,13.256,13.256H265.54c7.318,0,13.256-5.936,13.256-13.256V13.255C278.796,5.935,272.86,0,265.54,0z M252.284,252.287H26.515V26.511h225.769V252.287z',
      strokeColor: '#800000',
      scale: 0.05,
      fillOpacity: 1,
      strokeWeight: 1
  }
  //draw the marker and attach it to the map
  marker = new google.maps.Marker({
      position: markerLatLng,
      map: map,
      icon: iconImage,
      draggable: false
  });
  //add aditional properties to the marker
  marker.metadata = {
      id: id
  };
  
  //add the marker to the markers array
  currentlyDisplayedMarkers.push(marker);
  for (var j = 0; j &lt; currentlyDisplayedMarkers.length; j++) {
      var pathMarker = currentlyDisplayedMarkers[j];
      addClickHandler(pathMarker);
  }
  }
  function addClickHandler(pathMarker) {
  google.maps.event.addListener(pathMarker, 'click', function () {
      flightPath.setMap(map);
  });
  }
  </code></pre>