J
J
jeston2011-01-17 22:06:33
Google Maps
jeston, 2011-01-17 22:06:33

Programmatically show google map marker infoWindow (Google Maps API)?

1. I have a web page with a UL list and a Google map (work with the map is done through the Google Maps API).
2. Scripts form markers and information windows (infoWindow) on the map, waiting for a click, and if the user clicks, they are shown, as expected. (the text of each LI and the infoWindow text on the marker are the same, respectively)
3. But now I want to implement the display of this infoWindow by clicking on an element of the UL list. I implemented this stupidly - by clicking on LI, coordinates and text are extracted from its id and a new marker is formed on them, an infoWindow is added to it and it is added to the map and showInfoWindow is shown. Isn't there a way to access already existing markers on google map and show the infoWindow it already has?
Thanks :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EXSlim, 2011-01-18
@EXSlim

for API v3

google.maps.event.addDomListener(document.getElementById('li-id'), 'click', function() {
  infowindow.open(map, marker);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question