2011-10-24 75 views
1

我在編譯和運行設備(本例中爲iPhone)時顯示Google地圖時出現問題。如何使用Sencha和PhoneGap使用谷歌地圖視圖

如果我使用它沒有在MapOptions我得到的消息「谷歌地圖API需要」,如果我包括在MapOptions我只是得到了一個空白屏幕,地圖應該是...這似乎也打破它不會顯示爲啓動時的活動選項卡(它應該 - 它的第一個選項卡),並且您不能導航回選項卡...

任何人都可以告訴我什麼是我的錯誤嗎?我已經包括了地圖API的JS在我的索引文件...

ToolbarDemo.views.Mapcard = Ext.extend(Ext.Panel, { 
    title: "Map", 
    id: 'map', 

    dockedItems: [{ 
     xtype: "toolbar", 
     title: "Current location" 
    }], 
    //styleHtmlContent: true, 
    fullscreen: true, 
    layout: 'fit', 
    items: [ 
     { 
      xtype: 'map', 
      useCurrentLocation: true, 
      layout: 'fit', 
      id: 'cadwmap', 
      mapOptions: { 
       //center : new google.maps.LatLng(50.077721, 14.448585), 
       zoom: 12, 
       mapTypeId : google.maps.MapTypeId.ROADMAP 
       navigationControl: true, 
       navigationControlOptions: { 
        style: google.maps.NavigationControlStyle.DEFAULT 
       } 
      } 
     } 
    ], 

    initComponent: function() { 
     ToolbarDemo.views.Mapcard.superclass.initComponent.apply(this, arguments); 
    } 
}); 

Ext.reg('mapcard', ToolbarDemo.views.Mapcard); 
+0

剛試過你的代碼在Android上,它工作:( – SteveCav

回答

1

好吧,我想答案是,我不得不添加在PhoneGap的白名單,以谷歌在phonegap.plist文件相關領域

1

請確保您的index.html包括:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>