0

I'd like to have a limit of one open InfoWindow on my screen. At this point you can have multiple (there are 100 items on my screen) InfoWindows, by clicking on the markers.

If you click on a marker, a InfoWindow will pop up:

google.maps.event.addListener(marker, 'click', function() {
    infowindow.close();
    infowindow.open(map,marker);
});

Markers are made like this:

var marker = new google.maps.Marker({
    position: myLatLng,
    map: map,
    icon: pinIcon
});

gmarkers.push(marker);

How is it possible for me to have a limit of only one open InfoWindow?

SilverlightFox
  • 32,436
  • 11
  • 76
  • 145
0846277
  • 73
  • 3
  • 11

1 Answers1

0

Solution:

google.maps.event.addListener(marker, 'click', function() {
    for (i = 0; i < infoArray.length; i++) {
        infoArray[i].close();
    }

    infowindow.close();
    infowindow.open(map,marker);
});

Ohyeah, dont forget to create a infoArray!

var infoArray = [];
Mick D
  • 172
  • 1
  • 2
  • 14