2013-05-22 97 views
1

我正在使用骨幹來開發地圖應用程序。如何在不使用谷歌加載器的情況下異步加載谷歌腳本?我試圖使用$ .getScript,但由於某種原因,它返回的Google全局對象沒有任何標準API函數,如google.maps.LatLng。在脊柱上加載谷歌地圖

我的代碼

$.getScript 'https://maps.googleapis.com/maps/api/js?key=XXX&sensor=false', -> 
    console.log google 
    mapOptions = 
    center: new google.maps.LatLng(-34.397, 150.644), 
    zoom: 8, 
    mapTypeId: google.maps.MapTypeId.ROADMAP 
    map = new google.maps.Map document.getElementById("map") 

回答

0

使用AJAX來代替getScript加入:

$.ajax({ 
    dataType: 'script', 
    data: params, 
    url: 'http://maps.google.com/maps/api/js'    
});