views:

209

answers:

1

How can I open up a map marker info window from a link outside of the map?

I've figured out how to open up the info window by clicking on the marker within the map with the following code:

GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml("<div>I'm a marker</div>");
});

However, I cannot figure out how to get it to work from a link outside of the map.

+2  A: 

It's likely you have more than one marker. Kill two birds with one stone and put them into a global array:

var markers = []

GEvent.addListener(marker, "click", function() {
    marker[i].openInfoWindowHtml("<div>I'm a marker</div>");
});

Then you can simply call this, where the value of i is the index position of the marker:

marker[i].openInfoWindowHtml(...your html...);
Diodeus