I have a Google Map with Various locations and I want to be able to goto and open the Info Window when a link - outside of the map is clicked.
Below is the relevant bits of the working code, but I want to put the links into a select drop down rather than just text links in a div
$('#markers').append('<a class="marker-link" data-markerid="' + i + '" href="#">' + locations[i][1] + '</a> ');
google.maps.event.addListener(marker, 'click', (function (marker, i) {
$('.marker-link').on('click', function () {
google.maps.event.trigger(markers[$(this).data('markerid')], 'click');
});
BTW there is the following div in the HTML
<div id="markers"></div>
To try and get it to work as a drop down I have changed this line
$('#markers').append('<a class="marker-link" data-markerid="' + i + '" href="#">' + locations[i][1] + '</a> ');
to
$('#dropdown').append('<option data-markerid="' + i + '">' + locations[i][1] + '</option>');
and then added this into the HTML
<select id="dropdown"></select>
I then do get a drop down with all the various titles and each option has
data-markerid="0"
data-markerid="1"
and I also added
$( "#dropdown" ).change(function() {
google.maps.event.trigger(markers[$(this).data('markerid')], 'click');
});
But when I select an item from the drop down it does not go to and show the relevant InfoWindow