Javascript 单击事件google map添加标记Extjs

Javascript 单击事件google map添加标记Extjs,javascript,google-maps,extjs,google-maps-api-3,Javascript,Google Maps,Extjs,Google Maps Api 3,您好,我实现了点击事件,但什么都没有。我使用的是MVC Extjs,我知道如何在javascript中实现,例如简单点击事件,但在Extjs中,我应该把代码放在窗口中,我有gmappanel,如何在控制器中处理这个问题,我不知道怎么做。。。帮助我放置此代码的位置: var map = Ext.getCmp('gmapForm'); google.maps.event.addListener(map, 'click', function(e) { var lat = e.latLng

您好,我实现了点击事件,但什么都没有。我使用的是MVC Extjs,我知道如何在javascript中实现,例如简单点击事件,但在Extjs中,我应该把代码放在窗口中,我有gmappanel,如何在控制器中处理这个问题,我不知道怎么做。。。帮助我放置此代码的位置:

   var map = Ext.getCmp('gmapForm');
google.maps.event.addListener(map, 'click', function(e) {
    var lat = e.latLng.lat(); // lat of clicked point
    var lng = e.latLng.lng(); // lng of clicked point
    var markerId = getMarkerUniqueId(lat, lng); // an that will be used to cache this marker in markers object.
    var marker = new google.maps.Marker({
        position: getLatLng(lat, lng),
        map: map,
        id: 'marker_' + markerId
    });
}); 
以下是我对没有工作的听众没有人工作的看法,我想知道:

    Ext.define('App.view.App', {
        extend: 'Ext.window.Window',
        alias: 'widget.appform',
        title:'',
        operation:'',
       resizable: false,
        modal:true,
        initComponent: function () {
            me = this;
            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',
                    gmapType: 'map',
                    center: {
                        geoCodeAddr: "221B Baker Street",
                        marker: {
                            title: 'Holmes Home'
                        }
                    },
                    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
                },

            ];
            console.log(arguments);
            this.callParent(arguments);
        }
    });
这是我的控制器:

Ext.define('App.controller.AppController', {
    extend: 'Ext.app.Controller',
    views:  [
        'App.AppPanelView',

        'App.AppForm'

       ],
    stores: ['App.Apptore'],
    models: ['App.AppModel'],
    refs: [
        { ref: 'App', selector: 'AppForm' }


    ],

    init: function () {
        this.control({


            'App button[name="Add"]':{
                click:this.addPersonForm,
                afterrender:this.addMapListener
         }
        });
    },

    selectedRow:null,
    countryId:null,
    personProfile:null,
    modalImageIndex:null,
    imageId:null,
    avatar:"",



    addMarker:function(){
console.log("aaaaaaa");
       var win= Ext.widget('AppForm',{title:'Add Group',operation:'Add'});
        var trafficMap = Ext.getCmp('gmapForm');
      //  var marker_icon = new google.maps.MarkerImage('images/map/' + thisIcon + '.png', new google.maps.Size(32, 32));
        /*var trafficMarker = new google.maps.Marker({
            position: new google.maps.LatLng(alert.lat, alert.lon),
            map: trafficMap,
         //   icon: marker_icon,
            id: 'trafficAlertIcon'  *//*i*//*
        });*/

        /*var options = {
            lat:3.951941,
            lng:-102.052002,
            marker: {title:"Hello World!"},
            listeners: {
                click: function(e){

                }
            }
        };
        console.log(trafficMap);
       var lat = 3.951941,
            lng = 102.052002;
        var mpoint = new google.maps.LatLng(lat,lng);
        trafficMap.addMarker(mpoint,options.marker,false,false, options.listeners);*/

       /* google.maps.event.addListener(trafficMarker, 'mousedown', function()
        {
            console.log('touched marker');
           *//* trafficTabPanel.layout.setActiveItem(1, {type: 'slide', direction: 'left'});
            LoadIncidentMap(this.id.substring(16));*//*
        });
*/
       /* google.maps.event.addListener(trafficMap, "click", function (e) {
            console.log('click');

            //lat and lng is available in e object
         //   var latLng = e.latLng;

        });*/

        var addMarker = google.maps.event.addListener(trafficMap, 'click', function(e) {
            var lat = e.latLng.lat(); // lat of clicked point
            var lng = e.latLng.lng(); // lng of clicked point
            var markerId = getMarkerUniqueId(lat, lng); // an that will be used to cache this marker in markers object.
            var marker = new google.maps.Marker({
                position: getLatLng(lat, lng),
                map: map,
                id: 'marker_' + markerId
            });
            console.log(lat+  " "+  lng);

            //    markers[markerId] = marker; // cache marker in markers object
        //    bindMarkerEvents(marker); // bind right click event to marker
        });
        addMarker;
        console.log('clickaa');



        //win.show();
    },
    addMapListener:function() {
        console.log("A1");

        var trafficMap = Ext.getCmp('gmapForm');
        google.maps.event.addListener(trafficMap, 'click', function(e) {
            console.log("A3");

            var lat = e.latLng.lat(); // lat of clicked point
            var lng = e.latLng.lng(); // lng of clicked point
            var markerId = getMarkerUniqueId(lat, lng); // an that will be used to cache this marker in markers object.
            var marker = new google.maps.Marker({
                position: getLatLng(lat, lng),
                map: map,
                id: 'marker_' + markerId
            });

            console.log(lat+" "+lng);

            //    markers[markerId] = marker; // cache marker in markers object
            //    bindMarkerEvents(marker); // bind right click event to marker
        });
        console.log("A22");

        var map;
      //  map = new google.maps.Map($('#map')[0], myOptions);
       /* var myOptions = {
            zoom: 7,
            center: new google.maps.LatLng(46.87916, -3.32910),
            mapTypeId: 'roadmap'
        };
        google.maps.event.addListener(map, 'click', function(e) {
            console.log(A2);

            var lat = e.latLng.lat(); // lat of clicked point
            var lng = e.latLng.lng(); // lng of clicked point
            var markerId = getMarkerUniqueId(lat, lng); // an that will be used to cache this marker in markers object.
            var marker = new google.maps.Marker({
                position: getLatLng(lat, lng),
                map: map,
                id: 'marker_' + markerId
            });
            markers[markerId] = marker; // cache marker in markers object
            bindMarkerEvents(marker); // bind right click event to marker
        });*/

    }
});
我已经尝试了所有的方法为什么extjs是这个代码放在哪里