我正在尝试addListener(地图,'点击',功能(e)为我的gmappanel但它不起作用返回undef如何制作addListener(地图,'点击',功能(e)工作 有人可以告诉如何制作,因为我搜索所有的互联网,只找到javascript而不是extjs如何在点击上挂起该功能?onrender?帮助 我的观点:
Ext.define('Pandora.view.Group.GroupForm', {
extend: 'Ext.window.Window',
alias: 'widget.GroupForm',
title: '',
operation: '',
//width : 350,
//layout : 'fit',
resizable: false,
modal: true,
initComponent: function () {
me = this;
console.log(me.operation);
// console.log(me);
this.autoShow = true;
this.width = 550;
this.height = 650;
this.items = [
{
xtype: 'textfield',
name: 'title',
value: me.login,
fieldLabel: 'Title',
allowBlank: false,
width: 330,
style: {
marginTop: '10px',
marginLeft: '20px',
marginRight: '20px'
}
},
{
title: 'Google Map',
width: 535,
height: 800,
// frame:true,
id: 'gmapForm',
// height: '100%',
xtype: 'gmappanel',
/* listeners: {
click: function(e){
Ext.Msg.alert('It\'s fine', 'and it\'s art.');
}
}*/
/*afterrender: {
click: function (e) {
console.log("a++");
Ext.Msg.alert('point_lat',
'and its art.');
GEvent.addListener(this.map, "click",
function () {
alert("You clicked the map.");
});
}
// Ext.Msg.alert('It\'s fine', 'and it\'s art.');
//fn: setupWindow,
//scope: this
}*/
gmapType : 'map',
center
: {
geoCodeAddr: "221B Baker Street",
marker :
{
title: 'Holmes Home'
}
}
,
listeners:{
afterrender: {
fn: this.addMapListener,
scope: this
},
el: {
click: function (e) {
alert('click');
console.log(e.latLng);
}
/* google.maps.event.addListener(trafficMap, 'click', function(e) {
// infowindow.open(googleMapComp, marker);
console.log('sssssssssss');
})*/
}
},
/* listeners: {
click: function (e) {
console.log("a");
Ext.Msg.alert('point_lat',
'and its art.');
GEvent.addListener(this.map, "click",
function () {
alert("You clicked the map.");
});
}
},*/
mapConfOpts: ['enableScrollWheelZoom', 'enableDoubleClickZoom', 'enableDragging'],
mapControls
:
['GSmallMapControl', 'GMapTypeControl', 'NonExistantControl'],
mapOptions
:
{
mapTypeId: google.maps.MapTypeId.ROADMAP
}}
/*listeners: {
maprender: function(extMapComponent, googleMapComp){
var marker = new google.maps.Marker({
position: position = new google.maps.LatLng (42.16726190,-87.83146810),
// position: patientPosition, //patientPosition initialized in geocodePatientAddress() function in Home.js
map: googleMapComp,
animation: google.maps.Animation.DROP,
draggable: false,
title: 'Patient Location'
});
google.maps.event.addListener(marker, 'click', function() {
// infowindow.open(googleMapComp, marker);
console.log('sssssssssss');
});
google.maps.event.addListener(marker, 'mouseout', function() {
infowindow.close(googleMapComp, marker);
});
}
},*/
/* handler : function () {
google.maps.event.addListener(marker, 'click', function() {
// infowindow.open(googleMapComp, marker);
console.log('sssssssssss');
});
// this.up('window').down('form').getForm().reset();
}*/
/* google.maps.event.addListener(gObject, "click", function(e){
alert('test');
})*/
]
;
this.buttons = [
{
text: me.operation,
name: me.operation,
scope: this
},
{
text: 'Cancel',
scope: this,
handler: this.close
}
];
console.log(arguments);
this.callParent(arguments);
},
addMapListener:function(){
console.log("addMapListenervieew");
var trafficMap = Ext.getCmp('gmapForm');
google.maps.event.addListener(trafficMap, 'click', function(e) {
// infowindow.open(googleMapComp, marker);
console.log('sssssssssss');
});
/*GEvent.bind(this.gmap, 'click', this, function(){
// this.onMapReady();
});*/
// var me = this;
//Ext.widget('EventForm',{title:me.selectedRow.name+"'s Event",id:me.selectedRow.id});
}
/*GEvent.bind(this.gmap, 'click', this, function(){
this.onMapReady();
});*/
});