0

我正在尝试使用以下代码在我的应用中显示谷歌地图

<!DOCTYPE HTML>

    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <script scr="jquery.js></script>
    <link rel="stylesheet" href="jquery.mobile-1.3.0.css" />
    <script type="text/javascript" src="cordova-2.4.0.js"></script>
    <script type="text/javascript" src="jquery.mobile-1.3.0.min.js"></script>

<style type="text/css">
    html, body, #map-canvas {
        margin: 0;
        padding: 0;
        height: 100%;
    }

</style>

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></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);
    }
    google.maps.event.addDomListener(window, 'load', initialize);
    </script>

当我的 MainActivity.java 像这样时,它工作正常

import org.apache.cordova.DroidGap;
import android.os.Bundle;
import android.webkit.WebView;
public class MainActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);     
    setContentView(R.layout.activity_main);
    WebView myBrowser = (WebView)findViewById(R.id.mybrowser);
    myBrowser.loadUrl("file:///android_asset/www/index.html");
    myBrowser.getSettings().setJavaScriptEnabled(true);

}     }

但是我使用时没有显示谷歌地图

super.loadUrl("file:///android_asset/www/index.html");

他们有什么办法解决这个问题。提前致谢。

4

1 回答 1

0

尝试改变元

<meta http-equiv="Content-Security-Policy"
          content="default-src *;
               script-src 'self' 'unsafe-inline' 'unsafe-eval'
                           127.0.0.1:*
                           http://*.google.com
                           http://*.gstatic.com
                           http://*.googleapis.com
                           http://*.firebaseio.com
                           https://*.google.com
                           https://*.gstatic.com
                           https://*.googleapis.com
                           https://*.firebaseio.com
                           ;
               style-src  'self' 'unsafe-inline'
                          127.0.0.1
                           http://*.google.com
                           http://*.gstatic.com
                           http://*.googleapis.com
                           http://*.firebaseio.com
                           https://*.google.com
                           https://*.gstatic.com
                           https://*.googleapis.com
                           https://*.firebaseio.com
">

和谷歌脚本<script src="https://maps-api-ssl.google.com/maps/api/js?libraries=places"></script>

于 2015-08-19T07:06:31.533 回答