2011-08-04 3 views
1

마커로 문제를 해결 한 후에 다른 문제가 있습니다. 이번에는 지도를 사용하여 패널을 만든 후에 (on 또는 addListener 메서드 사용) 수신기를 추가 할 수 없습니다.Sencha Touch :지도에 청취자를 추가 할 수 없습니다. 도와주세요?

도움을 주시면 감사하겠습니다. 여기 코드는 다음과 같습니다

Ext.setup({ 
... 
onReady: function() { 

    var TopBar, Tabs, MapHome, Viewport, Homecard, Nearbycard, updateNearby; 

    /* 
    *  HOME 
    */ 
    var markersHome = []; 
    MapHome = new Ext.Map({ 
     id: "maphome", 
     title: 'Map', 
     useCurrentLocation: true, 
     listeners: { 
      centerchange: function(comp, map){ 
       deleteOverlays(markersHome); //defined on another file 
       addMarker(markersHome,map.center); //defined on another file 
       showOverlays(markersHome,map); //defined on another file 
      } 
     }, 
     mapOptions : { 
      mapTypeControl : false, 
      navigationControl : false, 
      streetViewControl : false, 
      backgroundColor: 'transparent', 
      disableDoubleClickZoom: true, 
      zoom: 17, 
      draggable: false, 
      keyboardShortcuts: false, 
      scrollwheel: false, 
      mapTypeId: google.maps.MapTypeId.HYBRID 
     } 
    }); 


    Homecard = new Ext.Panel({ 
     title: "home", 
     id: "homecard", 
     iconCls: "home", 
     items: [MapHome] 
    }); 

    /* 
    *  NEARBY 
    */ 
    Nearby = new Ext.List({ 
     scroll: 'vertical', 
     height: '100%', 
     styleHtml: true, 
     store: new Ext.data.Store({ 
      model: 'Places', //defined on another file 
      sorters: 'title', 
      data: [] 
     }), 
     itemTpl:['<div class="nearby-item" id="{id}">', 
        '<img alt="{title}" src="{imageUrl}" />', 
        '<h2>{title}</h2>', 
        '<p>{excerpt}</p>', 
       '</div>'] 
    }); 

    Nearbycard = new Ext.Panel({ 
     fullscreen: true, 
     iconCls: "list", 
     title: "nearby", 
     id: "nearbycard", 
     items: [Nearby] 
    }); 

    updateNearby = function() { 
     console.log('updating!'); //debug purposes 
     } 
    MapHome.on('locationupdate',updateNearby); // <-- Here is the problem 



    /* 
    *  MAIN 
    */ 

    TopBar = new Ext.Toolbar({ 
     dock: 'top', 
     xtype: "toolbar", 
     title: "<img class='titleLogo' src='css/images/logo.png' />", 
     items: [ 

      { xtype: 'spacer' }, 
      { 
       iconCls: 'settings9', 
       iconMask: true, 
       text: 'options' 
      } 
     ] 
    }); 

    Tabs = new Ext.TabPanel({ 
     id: 'tabs', 
     //fullscreen:true, 
     dock: 'bottom', 
     flex: 1, 
     tabBar: { 
      dock: 'bottom', 
      layout: { 
       pack: 'center' 
      } 
     }, 
     items: [ Homecard, Nearbycard ] 
    }); 

    Viewport = new Ext.Panel({ 
     fullscreen:true, 
     layout:{type:'vbox',align: 'stretch'}, 
     ui:'dark', 
     items: [TopBar,Tabs], 
    }); 
} 
}); 

나는 MapHome.on 코드 라인에이 오류가 계속 :

Uncaught TypeError: Cannot read property 'element' of undefined

+0

고정. 변수를 정의하는 중 오류가 발생했습니다. 위의 코드가 올바르게되었습니다. – vascomotaborges

답변

0

내가 그 작동하는지

MapHome.map.on(……………………); 

참조해야한다고 생각합니다. 만약 당신이 여기에 알고 완벽하게 코드에 붙여 넣으십시오 :