gpt4 book ai didi

javascript - Cordova map 未在 Framework7 中加载

转载 作者:行者123 更新时间:2023-11-28 10:48:34 25 4
gpt4 key购买 nike

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

最佳答案

您可能需要使用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);
}*

尝试使用演示应用程序,该演示应用程序使用适用于 cordova 的 Google Maps SDK:https://github.com/mapsplugin/cordova-plugin-googlemaps

关于javascript - Cordova map 未在 Framework7 中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38529674/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com