Skip to content Skip to sidebar Skip to footer

How To Keep Single Info Window Open At The Same Time In Google Map V3?

aI know that this one is repeated question, I am using google map v3 on my Django web based applicaiton. Where i am using Markers, Infowindow and polyline. Everything works fine, e

Solution 1:

Instead of multiple infoWindows use only one instance.

When clicking on a marker, first close the infoWindow, then set the new content and open the infoWindow.

functionadd_marker(lat,lng,title,box_html) 
{
  //create the global instance of infoWindow if(!window.infowindow)
  {
    window.infowindow=new google.maps.InfoWindow();
  } 

  var marker = new google.maps.Marker({
      position: new google.maps.LatLng(lat,lng),
      map: map,
      title: title
  });

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

  return marker;
}

Post a Comment for "How To Keep Single Info Window Open At The Same Time In Google Map V3?"