2016-07-22 53 views
1

我想在科爾多瓦谷歌地圖在Framework7 HTML整合,但其不顯示任何地圖,雖然我已經寫了類似的代碼爲正常的HTML頁面,並在那裏工作。任何幫助將不勝感激。科爾多瓦地圖不加載在Framework7

// Wait for device API libraries to load 
// 
document.addEventListener("deviceready", onDeviceReady, false); 

// device APIs are available 
// 
function onDeviceReady() { 
    //navigator.geolocation.getCurrentPosition(onSuccess, onError); 
    var mapDiv = document.getElementById('map_canvas'); 
    var GOOGLE = new plugin.google.maps.LatLng(37.422858, -122.085065); 
    var map = plugin.google.maps.Map.getMap(mapDiv); 
    map.addEventListener(plugin.google.maps.event.MAP_READY, function() { 
     map.setCenter(GOOGLE); 
    }); 

} 
</script> 

回答

0

您可能需要使用google.maps.event.addDomListener(window, 'load', initialize);,嘗試使用domlistener內deviceready加載google library異步。

*function loadAsynchronousScript() { 
var script = document.createElement('script'); 
script.type = 'text/javascript'; 
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp' +'&signed_in=true&callback=initialize'; 
document.body.appendChild(script); 
}* 

嘗試播放與周圍的演示應用程序,該演示應用程序使用谷歌地圖SDK科爾多瓦:https://github.com/mapsplugin/cordova-plugin-googlemaps