I have markers on a map and a list of coordinates in a < ul > dynamically loaded.
I need to get the marker id by clicking on the coordinates < li >.
Would somebody have the solution?
Thanks by advance :)
Ok i found the solution by myself. On click on list element, i've run a loop on markers array and compared if marker.id had equal proprieties to the coordinates list element (data-latitude and data-longitude).
$(document).on('click','li', function(){
for( i=0; i<markers.length; i++ ) {
if (markers[i].lat === $(this).data('latitude') || markers[i].lat === $(this).data('longitude') ) {
google.maps.event.trigger(markers[i], 'click');
break;
}
}
});
I hope that can help someone ;)