嗨,我正在用感应器实现google地图,如下所示:google映射在sencha touch 2中的实现( MVC方式)
但是,当地图出现时,它首先显示一个默认位置(在美国的某个地方),然后重新呈现,以便根据我的配置显示地图。我怎么才能避免这种情况?
Ext.define('App.view.Map', {
extend: 'Ext.Map',
xtype: 'map',
useCurrentLocation: false,
config: {
layout: 'fit',
iconCls: 'icon-location',
title: 'Location',
styleHtmlContent: true,
items: {
docked: 'top',
xtype: 'titlebar',
title: 'Location'
}
},
mapOptions: {
center: new google.maps.LatLng(<value>, <value>),
disableDefaultUI: true
},
constructor: function(config) {
this.callParent(config);
if (!(window.google || {}).maps) {
this.setHtml('<p id="maperror">Internet Connection Required!</p>');
}
}
});发布于 2013-08-19 11:18:24
您定义了地图视图并扩展了Ext.Map,这样视图就变成了映射,当您将x类型赋予视图时,它不应该是预定义的x类型,如map、面板、按钮等等。
您应该学习Ext类系统并尝试使用以下代码。
Ext.define('myapp.view.Map', {
extend: 'Ext.Map',
xtype: 'mymap',
config: {
layout: 'fit',
iconCls: 'icon-location',
title: 'Location',
useCurrentLocation: false,
styleHtmlContent: true,
items: [{
docked: 'top',
xtype: 'titlebar',
title: 'Location'
}],
mapOptions: {
center: new google.maps.LatLng(<value>, <value>),
disableDefaultUI: true
}
},
constructor: function(config) {
this.callParent(config);
if (!(window.google || {}).maps) {
this.setHtml('<p id="maperror">Internet Connection Required!</p>');
}
}
});发布于 2013-08-19 11:17:42
https://stackoverflow.com/questions/18312191
复制相似问题