2013-01-23 18 views
-1

我正在創建Google Maps混搭。 似乎一切正常,直到我嘗試將JQuery選項卡傳遞給我的infowindow。 基本上,我做的是:Google Maps/Jquery/Tabs - 無法讀取屬性__e3_的undefined

  1. 從複選框
  2. 創建地圖
  3. onclick事件創建標記
  4. 製造信息窗口
  5. 調用自定義函數生成的信息窗口的HTML(在此自定義函數,我給HTML元素一個唯一的名稱)
  6. 然後我嘗試調用JQuery函數來初始化標籤

這是問題出現的地方。我得到的javascript錯誤「無法讀取屬性_e3未定義」。我曾嘗試創建信息窗口後調用自定義的功能,但是這並沒有幫助(雖然這是那裏的JS問題出現)

我的代碼如下:

var map; 
     var mouseInfowindow; 
     var infowindow; 
     var bounds; 
     var infoWindow = new google.maps.InfoWindow; 
     var markers = []; 

     function initialize() { 
      var myOptions = { 
       center: new google.maps.LatLng(-33.924868, 18.424055), 
       mapTypeId: google.maps.MapTypeId.ROADMAP, 
       streetViewControl: true, 
       zoomControl: true, 
       panControl: true, 
       mapTypeControl: true, 
       zoom: 12, 
       zoomControlOptions: { 'style': google.maps.ZoomControlStyle.LARGE, 'position': google.maps.ControlPosition.RIGHT_BOTTOM }, 
       panControlOptions: { 'style': google.maps.ZoomControlStyle.LARGE, 'position': google.maps.ControlPosition.RIGHT_BOTTOM }, 
       mapTypeControlOptions: { 'style': google.maps.MapTypeControlStyle.DROPDOWN_MENU, 'position': google.maps.ControlPosition.RIGHT_BOTTOM } 
      }; 

      map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 

      devcs = []; 

      for (var i = 0; i < unitsArr.length; i++) { 
       var unit = unitsArr[i]; 
       var marker = createMarker(unit[0], unit[1], unit[2], unit[3], unit[4], unit[5]); 

       devcs[i] = marker; 
       mymarker = marker; 

       myLat = unit[2]; 
       myLng = unit[3]; 
      } 

      //ShowClock(); 
     } 

     function createMarker(a, b, c, d, e, f, g, h , i, j) 
     { 

      // Hide the Marker and InfoWindow if the checkbox was unchecked 
      if (j.checked == false) 
      { 
       hideMarker(a); 
      } 
      else 
      { 
       // If the marker was created previously, simply show it (i.e. do not recreate it) 
       if (show(a) == '0') 
       { 
        // Create new marker that has not already been added to the page 
        var location = new google.maps.LatLng(c, d); 
        var marker = new google.maps.Marker({ 
         position: location, 
         icon: e, 
         animation: google.maps.Animation.DROP, 
         map: map, 
         id: a 
         }); 

        marker.setTitle(b); 
        map.panTo(location); 
        markers.push(marker); 

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

         var contentString = buildInfoWindowContent(a, b, c, d, e, f); 
         infoWindow.setContent(htmlEscape(contentString)); 
         infoWindow.open(map,marker); 

         google.maps.event.addListener(infowindow, 'domready', function() { 
          $("#tab-panel-1234").tabs(); 
         }); 

        }); 
       } 
      } 
     } 


     function buildInfoWindowContent(a, b, c, d, e, f) 
     { 

      var returnString = '<div class="infobox-wrapper">' + 
           '  <div class="container_12" id="infobox" style="height:240px;overflow-y:auto;">' + 
           '   <div class="grid_12">' + 
           '    <div class="block-border" id="tab-panel-1234" style="width:610px;">' + 
           '     <div class="block-header">' + 
           '      <h1 id="MainTabTitle">' + b + '</h1>' + 
           '      <ul class="tabs">' + 
           '       <li><a href="#tab-1" id="TabOneHeader">Current</a></li>' + 
           '       <li><a href="#tab-2" id="TabTwoHeader">Trails</a></li>' + 
           '       <li><a href="#tab-3" id="TabThreeHeader">Download</a></li>' + 
           '      </ul>' + 
           '     </div>' + 
           '     <div class="block-content tab-container" style="padding-top:10px; padding-bottom:10px;">' + 
           '      <div id="tab-1" class="tab-content">' + 
                 f + 
           '      </div>' + 
           '      <div id="tab-2" class="tab-content">' + 
           '      <table style="width:100%;" cellpadding="4" cellspacing="0">' + 
           '       <tr>' + 
           '        <td></td>' + 
           '        <td></td>' + 
           '       </tr>' + 
           '       <tr>' + 
           '        <td></td>' + 
           '        <td></td>' + 
           '       </tr>' + 
           '      </table>' + 
           '      </div>' + 
           '      <div id="tab-3" class="tab-content">' + 
           '       <p>' + 
           '       </p>' + 
           '      </div>' + 
           '     </div>' + 
           '    </div>' + 
           '   </div>' + 
           '  </div>' + 
           ' </div> ' ; 

       return returnString; 

     } 

任何幫助將不勝感激!

回答

0

有一個錯字,標記W¯¯必須大寫:

google.maps.event.addListener(infowindow, 'domready',.... 
//--------------------------------^ 
+0

後已經坐在這,拉我的頭髮約3小時......你直接打一針見血。 非常感謝你! – SQLGuru

相關問題