• Hi, I’ve spent some thime over the issue of closing infoboxes in the Avatar map. So there is my solution. Please have in mind that I am no coder – I just searched the web for similar solutions and tried to apply the here.

    Problem no1 – infoboxes wont close so after clicking several avatars you wont see the map.
    Problem no2 – infobox wont close after you click empty space on the map.
    Fix – now when you click the other avatar, the previous infobox dissapears. If you click the map, the current avatar will also disappear.

    What to do:

    In file bp-members-avatar-map/mam.php you need to do following things:

    1. First you have to define a variable outside the showadress and showAddress_online function:
    var openedInfoWindow = null;

    2. Than you have to change the a piece of code in both of these function from:

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

    to

    google.maps.event.addListener(marker, 'click', function() {
        	if (openedInfoWindow != null) openedInfoWindow.close();
    	infowindow.open(map,marker);
    	openedInfoWindow = infowindow;
    	google.maps.event.addListener(infowindow, 'closeclick', function() {
              openedInfoWindow = null;
    
    	});
      	});
    	google.maps.event.addListener(map, 'click', function() {
    	infowindow.close();}) ;
    	}

    The solution for problem no 1 was ripped off from mkimanas post here. Thanks man!
    The solution for the problem no 1 was inspired by kdev respons here. Thanks!

    https://www.ads-software.com/extend/plugins/bp-members-avatar-map/

Viewing 1 replies (of 1 total)
  • @brxx —> Thanks for adding this.

    I fixed a couple of bugs in the original script that was added (above). Use this instead:

    1. You still need to add this as a global variable:

    var openedInfoWindow = null;

    2. Find this code:

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

    3. Replace it with this code:

    google.maps.event.addListener(marker, 'click', function() {
    	if (openedInfoWindow != null)
    		openedInfoWindow.close();
    	infowindow.open(map,marker);
    	openedInfoWindow = infowindow;
    	google.maps.event.addListener(infowindow, 'closeclick', function() {
    		openedInfoWindow = null;
    	 });
    	google.maps.event.addListener(map, 'click', function() {
    		infowindow.close();
    	}) ;
    });

Viewing 1 replies (of 1 total)
  • The topic ‘hiding infowindows on the map – solution’ is closed to new replies.