Close marker popup of google maps

Hi, I have integrated google map following this tutorial and works fine but when I touch in a marker and a Popup is showed, if I touch in other mark or position in the map, the previous marker popup is not close. So I have to close every popup manually.

Any idea?
Kind Regards

....
....
var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

var mapOptions = {
  center: latLng,
  zoom: 15,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};

$scope.map = new google.maps.Map(document.getElementById("map"), mapOptions);

google.maps.event.addListenerOnce($scope.map, 'idle', function() {
  //My position:
   var image = {
      url: 'img/myposition.png',
      size: new google.maps.Size(32, 32),
      origin: new google.maps.Point(0, 0),
      anchor: new google.maps.Point(10, 20)
   };

   var myStyle = {
      'background-image': 'url("img/myposition.png")'
   };

  var myMark = new google.maps.Marker({
      map: $scope.map,
      animation: google.maps.Animation.DROP,
      position: latLng,
      icon: image,
      options: {
        labelAnchor: "36 61",
         labelClass: 'labelClassMyPosition',
         labelStyle: myStyle,
         labelInBackground: false
      }
  });
   var myName = "<h4>" + "You're here" + "</h4>";
   addInfoWindow(myMark, myName, myMark);

  });

....
....
....
  function addInfoWindow(marker, message, record) {

      var infoWindow = new google.maps.InfoWindow({
        content: message
      });

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

   };

I added a timeout for close the popup but I want to close it by clicking on another marker or map.

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

little late for the reply but try this one working for me

Google map marker InfoWindow