Cordova Map未在Framework7

时间:2016-07-22 15:01:17

标签: javascript cordova google-maps html-framework-7

我正在尝试在Framework7 html中集成cordova谷歌地图,但它没有显示任何地图,虽然我已经编写了类似的代码,正常的HTML页面和它在那里工作。任何帮助将受到高度赞赏。

    

// 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>

1 个答案:

答案 0 :(得分:0)

您可能需要使用google.maps.event.addDomListener(window, 'load', initialize);,尝试在deviceready中使用domlistener异步加载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);
}*

尝试使用演示应用,此演示应用使用Google Maps SDK for cordova:https://github.com/mapsplugin/cordova-plugin-googlemaps