2015-01-09 92 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);    
     });