大家好我发现很难设置回拨功能,我有一个列表,在我的控制器中,我正在尝试收听列表中的每个项目,这样一旦每个项目被录音,它就会显示带有标记的地图,该标记指向我的商店中为该特定项目指定的指定纬度和日志。我认为itemtap甚至会是最好的,但我不知道如何在我的控制器中设置它。
我的商店:
Ext.define('List.store.Presidents', {
extend : 'Ext.data.Store',
config : {
model : 'List.model.President',
sorters : 'lastName',
storeId: 'contactmap',
grouper : function(record) {
return record.get('lastName')[0];
},
data : [{
firstName : "Ikhlas HQ",
lastName : "Tower 11A, Avenue 5, Bangsar South, No.8 Jalan Kerinchi 59200 Kuala Lumpur",
lat : 3.110649,
lng : 101.664991,
id: '200',
},
{
firstName : "PEJABAT WILAYAH SELANGOR",
lastName : "No. 97, 97-1 & 97-2, Jalan Mahogani 5/KS7, Ambang Botanic, 41200 Klang, Selangor",
lat : 3.003384,
log : 101.45256,
id: '001',
},]}
});
这是我的控制器:
Ext.define('List.controller.Main', {
extend: 'Ext.app.Controller',
config: {
refs: {
main: 'mainpanel',
},
control: {
'presidentlist': {
disclose: 'showDetail'
},
} },
showDetail: function(list, record) {
this.getMain().push({
xtype: 'presidentdetail',
title: record.fullName(),
data: record.getData(),
listeners: {
itemtap : function(component, map, geo, eOpts) {
var contactmap = Ext.getStore('contactmap');
contactmap.load({
callback:function(records,map,componet,lad,log){
var position = new google.maps.LatLng();
}
var marker = new google.maps.Marker({
position: position,
map: map
});
var infowindow = new google.maps.InfoWindow({
content: 'Working Fine'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
});
},
},
})
},
});
希望我能在这里得到一些帮助,以便在此时陷入困境。感谢
答案 0 :(得分:0)
Ext.define('List.controller.Main', {
extend: 'Ext.app.Controller',
config: {
refs: {
myList: 'presidentlist', // 'presidentlist' is xtype of your list
},
control: {
myList: {
itemtap: 'onMyListItemTap'
},
}
},
onMyListItemTap: function(list, index, target, record, e, eOpts) {
// some functionality here
var myLat = record.data.lat; // etc.
var myLng = record.data.lng; // etc.
}
答案 1 :(得分:0)
我的控制器:
Ext.define('List.controller.Main', {
extend: 'Ext.app.Controller',
config: {
refs: {
main: 'mainpanel',
},
control: {
myList: {
itemtap: 'onMyListItemTap'
},
'presidentlist': {
disclose: 'showDetail'
},
}
},
showDetail: function(list, record) {
this.getMain().push({
xtype: 'presidentdetail',
title: record.fullName(),
onMyListItemTap: function(list, index, target, record, e, eOpts) {
var position = new google.maps.LatLng();
var myLat = record.data.lat;
var myLng = record.data.lng;
var marker = new google.maps.Marker({
position: position,
map: map
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
setTimeout(function() {
map.panTo(position);
}, 1000);
},
});
},
});
我的商店:
Ext.define('List.store.Presidents', {
extend : 'Ext.data.Store',
config : {
model : 'List.model.President',
sorters : 'lastName',
storeId: 'contactmap',
grouper : function(record) {
return record.get('lastName')[0];
},
data : [{
firstName : "Ikhlas HQ",
lastName : "Tower 11A, Avenue 5, Bangsar South, No.8 Jalan Kerinchi 59200 Kuala Lumpur",
lat : 3.110649,
log : 101.664991,
id: '200',
},
{
firstName : "PEJABAT WILAYAH SELANGOR",
lastName : "No. 97, 97-1 & 97-2, Jalan Mahogani 5/KS7, Ambang Botanic, 41200 Klang, Selangor",
lat : 3.003384,
log : 101.45256,
id: '001',
}, {
firstName : "PEJABAT WILAYAH KEDAH",
lastName : "57, Jalan Lagenda 3, Legenda Heights, 08000, Sungai Petani, Kedah Darul Aman",
lat : 5.657754,
log : 100.50014,
id: '002',
},]
},
});
我的模特:
Ext.define('List.model.President', {
extend : 'Ext.data.Model',
config : {
store: 'Presidents',
fields : ['firstName', 'middleInitial', 'lastName', 'lat', 'log', 'id']
},
fullName : function() {
var d = this.data, names = [d.firstName, (!d.middleInitial ? "" : d.middleInitial + "."), d.id];
return names.join(" ");
}
});