用标记解决了我的问题之后我又遇到了另一个问题。这次,在使用地图创建面板后,无法添加监听器(使用on
或addListener
方法)。
非常感谢任何帮助。这是代码:
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
代码
未捕获的TypeError:无法读取未定义的属性'element'
答案 0 :(得分:0)
我认为应该是
MapHome.map.on(……………………);
看看是否有效。如果它不知道在这里和il粘贴在你的完美代码:)