Sencha touch Sencha Touch 2点击按钮获取当前位置
我有一个工具栏按钮,单击该按钮时应将地图更新到当前位置。我找不到这个功能的工作示例,希望有人能给我提供建议。请参阅下面的示例代码-感谢您的帮助 地图: 工具栏按钮:Sencha touch Sencha Touch 2点击按钮获取当前位置,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,我有一个工具栏按钮,单击该按钮时应将地图更新到当前位置。我找不到这个功能的工作示例,希望有人能给我提供建议。请参阅下面的示例代码-感谢您的帮助 地图: 工具栏按钮: Ext.define('MyApp.view.btnLocateMe', { extend: 'Ext.Button', alias: 'widget.btnlocateme', config: { ui: 'normal', iconCls: 'locate',
Ext.define('MyApp.view.btnLocateMe', {
extend: 'Ext.Button',
alias: 'widget.btnlocateme',
config: {
ui: 'normal',
iconCls: 'locate',
iconMask: true,
text: 'Locate Me',
listeners: [
{
fn: 'onButtonTap',
event: 'tap'
}
]
},
onButtonTap: function(button, e, options) {
//Produces error: cannot call method of undefined
currentLocation: new google.maps.LatLng(this._geo.getLatitude(), this._geo.getLongitude());
MyApp.view.MyMap.map.setCenter(currentLocation);
}
});
我有一个建议
尝试将当前位置更改为
new google.maps.LatLng( this.geo.getLatitude(),this.geo.getLongitude() ) ;
我想你可以在中从这个问题中收集更多信息。最简单的方法-在配置中使用选项useCurrentLocation:true设置切换到另一个地图视图我的两美分贡献,试试这个 1在MyApp.view.Myap中替换 借 另外,我认为您应该将currentLocation声明为一个变量 这应该行得通。我在onButtonTap中使用了与您类似的逻辑,但在控制器中没有问题
致以最诚挚的问候您从何处获取此地理变量?问题是单击时应将我的地图更新到我的当前位置,切换到另一个视图,并将param useCurrentLocation设置为true可解决此问题。
new google.maps.LatLng( this.geo.getLatitude(),this.geo.getLongitude() ) ;
useCurrentLocation: false,
useCurrentLocation : {
autoUpdate : false
},
var currentLocation = ...