2013-02-05 179 views
2

我用sencha-cmd創建了一個新的sencha應用程序。我對此有點新。所以,我試圖創建一個地圖: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' 
       } 
      ] 
     } 

我已經包含了必要的谷歌地圖API的文件外,還要求Ext.Map

但是地圖上沒有37.381592中心,-122.135672,其集中在其他地方。我怎樣才能解決這個問題?

此外,如何訪問地圖對象?所以,我可以叫東西一樣.getCenter()

回答

1

不知道在定心,但你可以用事後做:

theView.setMapCenter({latitude: 37.381592, longitude: -122.135672}); 

至於獲取元素,你可以簡單地調用:

theView.getMap(); 

這是全部來自Sencha Touch 2 docs,FYI。我很想看看它是如何工作的,我很快就會在我的新應用中實現一個地圖。

編輯: 仔細看看它,你的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 
    } 
    } 
} 
... 
+0

編輯:是的,它應該 –