有人可以帮帮我吗?我在煎茶中有一张地图,可以跟踪我当前的位置并画线。但我也想要一个按钮来停止跟踪。所以我想设置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.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();
}
}
} ]
}]
});
}
});