1

I’m developing a website that incorporates a Google map v3 and I would like to know how to programmatically close the infowindows that can be opened when the user clicks on the icons that are loaded with the map. I don’t mean the infowindows opened when the markers the site places on the map are clicked on.

Is this possible?

Thanks in advance

1 Answers1

0
var marker = new google.maps.Marker({
                    map: $scope.map,
                    icon: image
                });


var infowindow = new google.maps.InfoWindow({
                    content: 'some text'
                });

marker.addListener('mousedown', function() {
                    infowindow.open($scope.map, marker);
                    if (!marker.open) {
                        infowindow.open($scope.map, marker);
                        marker.open = true;
                        setTimeout(function() {
                            infowindow.close();
                            marker.open = false;
                        }, 2000);

                    } else {
                        infowindow.close();
                        marker.open = false;
                    }
                });

In ur case u just have to replace marker with icon , icon or whatever must have a mousedown or click listener.

And marker.open & close is just a variable

Aishwat Singh
  • 4,331
  • 2
  • 26
  • 48