簡體   English   中英

Google Maps JavaScript:未捕獲的錯誤:屬性的值無效 <map> :[對象對象]

[英]Google Maps JavaScript : Uncaught Error: Invalid value for property <map>: [object Object]

我正在嘗試使用Google地圖。 我已將地圖加載到面板上。

我有一個疊加窗口,我在其中要求在地圖上顯示方向的來源和目標。 我通過Ext.getCmp('GMap');獲得了對地圖的引用Ext.getCmp('GMap');

但是,當我在chrome上運行它並檢查控制台窗口時,出現此錯誤。

Uncaught Error: Invalid value for property <map>: [object Object]

重疊式視窗的點擊處理程式的范例程式碼片段

listeners : {
   tap : function() {
      function showDirections(res) {
         var directionsService = new google.maps.DirectionsService();
         var directionsDisplay = new google.maps.DirectionsRenderer();

         var map = Ext.getCmp('GMap');
         directionsDisplay.setMap(map);
         directionsService.route(request, function(response, status) {
         if (status == google.maps.DirectionsStatus.OK) {
              directionsDisplay.setDirections(response);
         }
    });
  }
 }
}

jQuery也這樣做。 當您獲取$(“#GMap”)時,您將返回一個數組,其中實際元素為[0]。 getCmp()的結果getCmp()為實際的dom元素。 http://www.sencha.com/forum/showthread.php?122684-accessing-component-property-from-variable-dom-element-or-Ext.getCmp ()看起來很相似。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM