title: Google maps api, addListener to external hover event
body: <p>I'm trying to add mouseenter/ mouseleave event handlers that open infowindows with a Google Map. </p>
  
  <p>I have ten elements, each with an associated Google Maps infowindow.   I've added a data-marker attribute to my elements to determine which element corresponds with the respective markers/infowindows. </p>
  
  <p>My problem is that I'm not constructing variables correctly within the argument list.  Here it is:</p>
  
  <pre><code> ....standard google maps definition above.  double brackets are django context variables within a forloop loop. 
  
  infowindow[{{forloop.counter}}]= new google.maps.InfoWindow({
      content:contentString{{forloop.counter}}
      });
  
  
  var marker{{forloop.counter}} = new google.maps.Marker({
      position:latlng{{forloop.counter}},
      map:map,
      icon:image,
      animation: google.maps.Animation.DROP,
       title:"Click for more info"
      });
  
  
  google.maps.event.addListener(marker{{forloop.counter}},'click', function(){
      $.each(infowindow, function(name, value){
          this.close();
      }); 
      infowindow[{{forloop.counter}}].open(map,marker{{forloop.counter}});
  });
  
  {% endfor %}    
  {% endif %} 
  </code></pre>
  
  <p>}</p>
  
  <pre><code>$('.entries').mouseenter(function(){
     var num=$(this).attr('data-marker');
  
     $.each(infowindow, function(name, value){
      this.close();
    });
  
        var mk='marker'
    m=mk.concat(num);
  
  
     infowindow[num].open(map,m);
  
  });
  
  $('.entries').mouseleave(function(){
  
  $.each(infowindow, function(name, value){
      this.close();
  });
  
  
  });
  </code></pre>
  
  <p>Obviously, I can't just pass a string into the .open() method and expect it to work. I'm more surprised that I can't pass the variable 'num' into the array index 
  Thanks, 
  Brendan</p>