Closing info windows in google maps by clicking the map?

add listener to map's click event and close infoboxes in its handler

google.maps.event.addListener(map, "click", function(event) {
    for (var i = 0; i < ibArray.length; i++ ) {  //I assume you have your infoboxes in some array
         ibArray[i].close();
    }
});

I do that on typical websites, but don't see any reason it wouldn't work on mobile


google.maps.event.addListener(marker, 'click', function() {
    if(!marker.open){
        infoWindow.open(map,marker);
        marker.open = true;
    }
    else{
        infoWindow.close();
        marker.open = false;
    }
    google.maps.event.addListener(map, 'click', function() {
        infoWindow.close();
        marker.open = false;
    });
});

Works perfectly


Try this:

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

It is quite simple an should work as well.