sencha按钮停止 [英] sencha button stop

查看:156
本文介绍了sencha按钮停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我吗?我有一个sencha地图,可以跟踪我当前的位置,它绘制线。但我也想要一个按钮来停止跟踪。所以我想设置 autoUpdate:false; 但是我真的不知道该怎么做...



是我的代码

  Ext.application({
name:'Applicatie3。',
launch:function (){
var view = Ext.create('Ext.NavigationView',{
fullscreen:true,
items:[{
title:I'm lost,
xtype:'tabpanel',
items:[{
title:'Home',
xtype:'map',
iconCls:'home',
mapOptions:{zoom:20},
useCurrentLocation:true,
listeners:{
maprender:function(comp,map){
var marker = new google.maps。标记({
position:new google.maps.LatLng(),
map :map
}),
infowindow = new google.maps.InfoWindow({
content:'........'
}),
route = [],
geo = Ext.create('Ext.util.Geolocation',{
frequency:3000,
autoUpdate:true,
allowHighAccuracy:true,
listeners:{
locationupdate:function(geo){
polyline = new google.maps.Polyline({
path:route,
strokeColor:red,
strokeOpacity:1.0,
strokeWeight:5
} );
polyline.setMap(map),

// alert(route);
route.push(new google.maps.LatLng(geo.getLatitude(),geo.getLongitude()));

marker.setPosition(new google.maps.LatLng(geo.getLatitude(),geo.getLongitude()));

google.maps.event.addListener(marker,'click',function(){
infowindow.open(map,marker);
});

},
locationerror:function(geo,bTimeout,bPermissionDenied,bLocationUnavailable,message){
if(bTimeout){
alert('超时发生) ;
} else {
alert('Error occurred。');
}
}
}
});
geo.updateLocation();
}
}
}]
}]
});
}

});

解决方案

我用一个设置为false的全局变量解决了这个问题,当我按下开始按钮,然后变量变为true。在函数中,我有一个if(true){do location update},当变量设置为false时,位置更新不起作用。


Can someone please help me? I have a map in sencha that can track my current location and it draws lines. But I also want a button to stop tracking. So I want to set autoUpdate: false;But I seriously dont know how to do this...

This is my code

Ext.application({
name: 'Applicatie3.',
launch: function() {
    var view = Ext.create('Ext.NavigationView', {
        fullscreen: true,
        items: [{
            title: "I'm lost",
            xtype: 'tabpanel',
            items:[{
                title               : 'Home',
                xtype               : 'map',
                iconCls             : 'home',
                mapOptions          : { zoom: 20  },
                useCurrentLocation  : true,
                listeners           : {
                    maprender: function(comp, map){
                        var marker = new google.maps.Marker({
                            position    : new google.maps.LatLng( ),
                            map         : map
                        }),
                        infowindow = new google.maps.InfoWindow({
                            content     : '........'
                        }),
                        route = [ ],
                        geo = Ext.create('Ext.util.Geolocation', {
                            frequency         : 3000,
                            autoUpdate        : true,
                            allowHighAccuracy : true,
                            listeners         : {
                                locationupdate : function(geo) {
                                    polyline = new google.maps.Polyline({
                                        path : route,
                                        strokeColor: "red",
                                        strokeOpacity: 1.0,
                                        strokeWeight: 5
                                    });
                                    polyline.setMap(map),

                                    //alert(route);
                                    route.push( new google.maps.LatLng( geo.getLatitude(),geo.getLongitude() ) );

                                    marker.setPosition(new google.maps.LatLng( geo.getLatitude(),geo.getLongitude() ) );

                                    google.maps.event.addListener(marker, 'click', function() {
                                         infowindow.open(map, marker);
                                    });

                                },
                                locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) {
                                    if(bTimeout){
                                        alert('Timeout occurred.');
                                    } else {
                                        alert('Error occurred.');
                                    }
                                }
                            } 
                        });
                        geo.updateLocation();
                    }                   
                } 
            } ]
        }]
    });
}

});

解决方案

I solved this problem with a global variable which is set false and when I press the start button then the variable change to true. In the function I have a if(true) {do location update}, when the variable is set false then the location update don't work.

这篇关于sencha按钮停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆