gpt4 book ai didi

android - PhoneGap Google map - map 不显示

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:40:10 24 4
gpt4 key购买 nike

我正在编写一个使用 PhoneGap 并需要在其中集成 Google map 的应用程序。我使用了 Google 提供的在线文档中的这个示例:

   <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDlFl3vPEbgzrr-1KX5E20z_1DowB2ASus&sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>

如果我在网络浏览器(Chrome、FF、IE...)中打开它,它会正常工作。但是,在我的模拟器(和设备)中它只显示一个空白页。有什么建议吗?

最佳答案

出现此问题是因为我在同一个应用程序上使用了多个 html 页面。由于 phonegap 将使用 ajax 调用来替换索引页面的 dom,因此它也无法在这些页面上加载脚本。

这里有两种解决方案:

  1. 只使用一个 html 页面
  2. 加载第二个页面使用

    rel="外部"

关于android - PhoneGap Google map - map 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13222857/

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