【问题标题】:Cordova Map not loading in Framework7科尔多瓦地图未在 Framework7 中加载
【发布时间】:2016-07-22 15:01:16
【问题描述】:

我正在尝试将科尔多瓦谷歌地图集成到 Framework7 html 中,但它没有在那里显示任何地图,尽管我已经为普通的 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>

【问题讨论】:

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


    【解决方案1】:

    您可能需要使用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

    【讨论】:

    • Yasir 询问了 cordova-plugin-googlemaps,而不是 google maps javascript API v3。
    猜你喜欢
    • 1970-01-01
    • 2017-12-19
    • 2020-02-15
    • 1970-01-01
    • 1970-01-01
    • 2015-01-25
    • 2016-11-21
    • 1970-01-01
    • 2020-05-10
    相关资源
    最近更新 更多