2015-01-09 88 views
-1

在谷歌地图上,我想在显示Infowindow之前调整InfoWindow的初始布局。具体来说,我想做到这一点或只是点击之后eventL谷歌地图 - 修改infowindow css或单击事件后

  // on click    
      $(".tabs").hide(); 
      $("#summary").show(); 

这是在点击标记时(成功)创建信息窗口的代码。我需要找到添加上面的代码和事件的地方。

 // Renders the marker on the specified map 
     marker.setMap(map); 

     // create an InfoWindow 
     var infoWnd = new google.maps.InfoWindow();   

     // add content to your InfoWindow 
     infoWnd.setContent('<div class="scrollFix">' + infoWindowContent); 

     // add listener on InfoWindow - close last infoWindow before opening new one 
     google.maps.event.addListener(marker, 'click', function() { 

      //Close active window if exists 
      if(activeInfoWindow != null) activeInfoWindow.close(); 

      // Open InfoWindow 
      infoWnd.open(map, marker); 

      // Store new open InfoWindow in global variable 
      activeInfoWindow = infoWnd; 

      .... 

回答

0

尝试在'domready'事件上将侦听器放在InfoWindow上。当这触发时,然后将更改应用于InfoWindow的内容。

 // Renders the marker on the specified map 
     marker.setMap(map); 

     // create an InfoWindow 
     var infoWnd = new google.maps.InfoWindow();   

     // put a listener of InfoWindow, when "domready", make changes to content 
     google.maps.event.addListener(infoWnd, 'domready', function() { 
      $("span.tabs").hide(); 
      $("#summary_tab").show();      
     }); 

     // add content to your InfoWindow 
     infoWnd.setContent('<div class="scrollFix">' + infoWindowContent + "<div>"); 


     // add listener on InfoWindow for CLICK event- close last infoWindow before opening new one 
     google.maps.event.addListener(marker, 'click', function() { 


      //Close active window if exists 
      if(activeInfoWindow != null) activeInfoWindow.close(); 

      // Store new open InfoWindow in global variable 
      activeInfoWindow = infoWnd; 

      // Open InfoWindow 
      infoWnd.open(map, marker);    
     });