I have multiple marker.
I successfully able to openinfo box when clicked on each marker using this code ( yes its inside a loop of setting marker )
for (var i = 0; i < markers.length; i++) {
....
....
....
google.maps.event.addListener(marker, "click", function () {
//alert(this.html);
infowindow.setContent(this.html);
infowindow.open(map, this);
});
}
The above code work very well.
But now i want each marker’s infobox to open on button clicked outside the map. I tried something this in the same loop.
for (var i = 0; i < markers.length; i++) {
....
....
....
var chandu = document.getElementById(i);
google.maps.event.addDomListener(chandu, "click", function(){
infowindow.setContent(this.html);
infowindow.open(map, this);
//alert("Yo");
});
}
and i have the html button to click like this
<a href="#" id="0">0</a>
<a href="#" id="1">1</a>
<a href="#" id="2">2</a>
<a href="#" id="3">3</a>
<a href="#" id="4">4</a>
<a href="#" id="5">5</a>
But this clicking of html link part doesn’t woork
The working solution I have now looks something like this
And there is a function out of the for loop
Credit: I come up with this answer after looking into the source code of this sample http://gmaps-samples-v3.googlecode.com/svn/trunk/sidebar/random-markers.html