Javascript 在GmapPanel-extjs4中添加动态标记 这是一个id为mygooglemapcode的创建谷歌地图面板

Javascript 在GmapPanel-extjs4中添加动态标记 这是一个id为mygooglemapcode的创建谷歌地图面板,javascript,ajax,google-maps,extjs,extjs4,Javascript,Ajax,Google Maps,Extjs,Extjs4,这是当复选树单击复选框,复选框的状态为true时,然后在Google地图上添加标记 Ext.define('GoogleMarkerModel', { extend: 'Ext.data.Model', fields: ['Locating','MainPower','Acc','PowerOff','Alarm','Speed','Direction','Latitude','Longitude','DateTime','MainID', 'D

这是当复选树单击复选框,复选框的状态为true时,然后在Google地图上添加标记

 Ext.define('GoogleMarkerModel', {
            extend: 'Ext.data.Model',
            fields: ['Locating','MainPower','Acc','PowerOff','Alarm','Speed','Direction','Latitude','Longitude','DateTime','MainID', 'DeviceID','IOState','OilState']
        });

        var MarkerStore = Ext.create('Ext.data.JsonStore', {
            model: 'GoogleMarkerModel',
            autoLoad: true,
            proxy: {
                type: 'ajax',
                url: 'get-googlemarker.php',
                baseParams: {  //here you can define params you want to be sent on each request from this store
                            mainid: 'value1'
                            },
                reader: {
                    type: 'json',
                    root: 'images'
                }
            }
        });

        tree.on('checkchange', function(node){
            var data = node.data;
            Ext.MessageBox.show({
            title: 'Changed checkbox status',
            msg: 'MainID: ' + data.MainID + ' <br /> Checkbox status: ' + data.checked,
            icon: Ext.MessageBox.INFO
            });
            if (data.checked = true){

                MarkerStore.load({
                            params: {
                                    mainid: data.MainID
                                    }
                            })  
                         //after markerstore get the longtitude and latitude,add google map a marker at here
            }
        })
Ext.define('GoogleMarkerModel'{
扩展:“Ext.data.Model”,
字段:[‘定位’、‘主电源’、‘Acc’、‘断电’、‘报警’、‘速度’、‘方向’、‘纬度’、‘经度’、‘日期时间’、‘主ID’、‘设备ID’、‘IOState’、‘OilState’]
});
var MarkerStore=Ext.create('Ext.data.JsonStore'{
型号:'GoogleMarkerModel',
自动加载:对,
代理:{
键入:“ajax”,
url:'GetGoogleMarker.php',
baseParams:{//在这里,您可以定义希望从此存储的每个请求发送的参数
mainid:'value1'
},
读者:{
键入:“json”,
根:“图像”
}
}
});
树.on('checkchange',函数(节点){
var data=node.data;
Ext.MessageBox.show({
标题:“已更改复选框状态”,
msg:'MainID:'+data.MainID+'
复选框状态:'+data.checked, 图标:Ext.MessageBox.INFO }); 如果(data.checked=true){ MarkerStore.load({ 参数:{ mainid:data.mainid } }) //markerstore获得经度和纬度后,在此处添加google地图标记 } })
选中复选框后,将向
获取googlemarker.php
传递一个id,获取MarkerStore中数据库存储的最新经度和纬度,并在googlemap上显示该标记。
所有的编码都完成了,只需在Google地图上留下添加标记,如何在Google地图上动态添加标记?
标记将在函数
树内创建。在('checkchange',函数(节点)

用这个代码解决
 Ext.define('GoogleMarkerModel', {
            extend: 'Ext.data.Model',
            fields: ['Locating','MainPower','Acc','PowerOff','Alarm','Speed','Direction','Latitude','Longitude','DateTime','MainID', 'DeviceID','IOState','OilState']
        });

        var MarkerStore = Ext.create('Ext.data.JsonStore', {
            model: 'GoogleMarkerModel',
            autoLoad: true,
            proxy: {
                type: 'ajax',
                url: 'get-googlemarker.php',
                baseParams: {  //here you can define params you want to be sent on each request from this store
                            mainid: 'value1'
                            },
                reader: {
                    type: 'json',
                    root: 'images'
                }
            }
        });

        tree.on('checkchange', function(node){
            var data = node.data;
            Ext.MessageBox.show({
            title: 'Changed checkbox status',
            msg: 'MainID: ' + data.MainID + ' <br /> Checkbox status: ' + data.checked,
            icon: Ext.MessageBox.INFO
            });
            if (data.checked = true){

                MarkerStore.load({
                            params: {
                                    mainid: data.MainID
                                    }
                            })  
                         //after markerstore get the longtitude and latitude,add google map a marker at here
            }
        })
    function addDoctorLocation(options) 
    {
     var gm = Ext.getCmp('mygooglemap');
     var mpoint = new google.maps.LatLng(options.lat,options.lng);
     var marker = gm.addMarker(mpoint,options.marker,false,false, options.listeners);
    }

tree.on('checkchange', function(node){
        var data = node.data;

        if (data.checked == true){

        var options = {
        lat:lati,
        lng:longi,
        marker: {title:"Hello World!"},
        listeners: {
                     click: function(e){

                                         }
                    }     
        }     
        addDoctorLocation(options);           
        }       
    })