2016-07-22 54 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