我用sencha-cmd创建了一个新的sencha应用程序。我对此还是个新手。所以我试着创建了一个地图:
{
title: 'Map',
iconCls: 'locate',
layout: 'card',
useCurrentLocation: false,
fullscreen: false,
id: 'locationmap',
mapOptions: {
zoom: 12,
center : new google.maps.LatLng(37.381592, -122.135672),
navigationControl: true,
navigationControlOptions:
{
style: google.maps.NavigationControlStyle.DEFAULT
}
},
items: [
{
docked: 'top',
xtype: 'titlebar',
title: 'Getting Started'
},
{
xtype: 'map'
}
]
}我已经包含了必要的google maps文件,还包含了必需的Ext.Map
然而,地图不是以37.381592,-122.135672为中心,而是以其他地方为中心。我该如何解决这个问题呢?
另外,我如何访问地图对象?这样我就可以调用像.getCenter()这样的东西
发布于 2013-02-06 05:00:42
不确定是否居中,但您可以在事后使用以下命令:
theView.setMapCenter({latitude: 37.381592, longitude: -122.135672});至于获取元素,您可以简单地调用:
theView.getMap();这些都是从Sencha Touch 2 docs传来的仅供参考。我很有兴趣看看它是如何工作的,我很快就会在我的新应用程序中实现一个地图。
编辑:仔细看一下,您的mapOptions参数不应该在xtype: 'map'项上吗?
...
{
xtype: 'map',
useCurrentLocation: false,
mapOptions: {
zoom: 12,
center : new google.maps.LatLng(37.381592, -122.135672),
navigationControl: true,
navigationControlOptions:
{
style: google.maps.NavigationControlStyle.DEFAULT
}
}
}
...https://stackoverflow.com/questions/14715951
复制相似问题