|
//using the index provided by jquery.each() $('.google-map__trigger-item').each(function(i){ $(this).on('click', function(){ google.maps.event.trigger(markers[i], 'click'); }); }); |
OR
|
//using your id data attribute $('.google-map__trigger-item').each(function(){ $(this).on('click', function(){ var id = parseInt($(this).data('id').split('-')[1]) -1; google.maps.event.trigger(markers[id], 'click'); }); }); |
OR
|
function OpenInfowindowForMarker(index) { google.maps.event.trigger(markers[index], 'click'); } |
|
<ul class="google-map__trigger"> <li data-id="marker-1" class="google-map__trigger-item"> <a onclick="OpenInfowindowForMarker(1)">Trigger Marker 1</a></li> |
Reference