我正在使用 Cordova API 捕获地理位置,然后在成功后,我在 Google 地图上呈现当前位置。
当我第一次使用 get_position 时,我呈现一个表单,如下所示:
var geo_panel = new Ext.form.Panel({
useCurrentLocation: true,
fullscreen: true,
layout: 'fit',
items: obj
});
其中 obj 是定义为的工具栏
toolbar = Ext.create('Ext.Toolbar', {
docked: 'top',
alias : 'widget.geolocationToolbar',
ui: 'light',
defaults: {
iconMask: true
},
items: [
{
xtype: 'button',
ui: 'back',
text: 'Back',
// destroy form.Panel overlay and return to tree store view
handler: function() {
geo_panel.destroy();
}
},
{
xtype: 'button',
itemId: 'stopWatch',
text: 'StopWatch',
iconCls: 'arrow_right',
iconMask: true,
handler: function() {
EvaluateIt.utils.UtilityService.clear_watch();
}
},
{
xtype: 'selectfield',
itemId: 'accuracy',
autoSelect: false,
placeHolder: 'accuracy',
options: [
{text: ''},
{text: 'high', value: 5},
{text: 'med high', value: 10},
{text: 'medium', value: 15},
{text: 'med low', value: 20},
{text: 'low', value: 66}
],
listeners: {
change: function(field, value) {
if (value instanceof Ext.data.Model) {
value = value.get(field.getValueField());
}
console.log(value);
// set accuracy as config variable
EvaluateIt.config.accuracy = value;
}
}
},
{
iconCls: 'home',
handler: function() {
google_map.getMap().panTo(position);
}
}
]
});
这在我的表单面板中呈现得很好。
然后我的 onSuccess 方法传递一个参数以将 google_map 添加到 geo_panel 表单面板。我已经尝试过 geo_panel.add(toolbar, google_map),它可以工作,但是当我点击上方工具栏中的“返回”按钮时,我遇到了一个问题:
{
xtype: 'button',
ui: 'back',
text: 'Back',
// destroy form.Panel overlay and return to tree store view
handler: function() {
geo_panel.destroy();
}
},
我必须单击它两次:第一次破坏 google_map,然后第二次破坏工具栏。这是一种非常不受欢迎的行为。我已经尝试销毁 geo_panel 中的每个项目,但这会做其他奇怪的事情。这就像有多个 geo_panel 实例。有任何想法吗?