phonegap javascript google api在apk文件中不起作用

时间:2017-04-24 13:07:28

标签: javascript android cordova

我刚刚开始使用phonegap,我可以设法在浏览器和phonegap应用程序中查看地图,但是一旦我将项目转换为apk文件(在adobe build中),它就什么都没显示。

<!DOCTYPE html>
<html>
  <head>
    hello
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Security-Policy" content="script-src 'self' https://maps.googleapis.com/ https://maps.gstatic.com/ https://mts0.googleapis.com/ 'unsafe-inline' 'unsafe-eval'">
<style>
    body, html, #map {  margin: 0;width:100%;height:400px }
#map {
    position: relative;
    width:400px;
    height: :50%;
}

#map:after {
    width: 22px;
    height: 40px;
    display: block;
    content: ' ';
    position: absolute;
    top: 50%; left: 50%;
    margin: -40px 0 0 -11px;
    background: url('https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi_hdpi.png');
    background-size: 22px 40px;  
   pointer-events: none; 
}

    </style>



   <script src="https://maps.googleapis.com/maps/api/js?key=MY_KEY" async defer></script>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>


    <script type="text/javascript">
    document.addEventListener("deviceready", function(){

        var mapOptions = {
                zoom: 4,
                center: new google.maps.LatLng(-33, 151),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
        map = new google.maps.Map(document.getElementById('map'), mapOptions);

    }, false);



    </script>
  </head>
  <body>
    <div id="map"></div>

  </body>
</html>

请帮我弄清问题是什么。

0 个答案:

没有答案