android – PhoneGap谷歌地图 – 地图不显示

我正在编写一个使用PhoneGap的应用程序,需要在其中集成Google Maps.我使用了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 onl oad="initialize()">
    <div id="map_canvas" style="width:100%; height:100%"></div>
  </body>
</html>

如果我在网络浏览器中打开它(Chrome,FF,IE …),这可以正常工作.但是,在我的模拟器(以及设备)中,它只显示一个空白页面.有小费吗?

解决方法:

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

这里有两种解决方案:

>仅使用单个html页面
>使用加载第二页

相对=“外部”

相关文章

公司前端界面用的是vue,我要嵌入到Android中生成App第一步:...
Q:我用cordova开发项目,想在app内跳转外部链接,安装了cord...
我正在使用https://github.com/arnesson/cordova-plugin-fir...
一、Cordova的基础点在混合式应用中,我们通过现有的Cordova...
cordova自定义插件注意:存放自定义cordova插件目录不能有空...
一、问题VueAPP中有一个文件下载功能,用了各种方法来实现下...