首页 文章

使用谷歌 Map 插件与科尔多瓦显示空白 Map

提问于
浏览
0

我想在我的cordova应用程序中使用谷歌 Map 插件 . 我用以下命令成功创建了我的sha1键:

keytool -exportcert -alias androiddebugkey -keystore C:\ Users \ Morsali.android \ debug.keystore -list -v

我成功创建了我的android和IOS Key . 包名称,sha1,...正确导入:

enter image description here

但是当我使用以下index.html页面构建我的应用程序时,我看到一个只有谷歌图标的空白 Map :

enter image description here

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript">
    var map;
    document.addEventListener("deviceready", function() {
      var div = document.getElementById("map_canvas");

      // Initialize the map view
      map = plugin.google.maps.Map.getMap(div);

      // Wait until the map is ready status.
      map.addEventListener(plugin.google.maps.event.MAP_READY, onMapReady);
    }, false);

    function onMapReady() {
      var button = document.getElementById("button");
      button.addEventListener("click", onBtnClicked, false);
    }

    function onBtnClicked() {
      map.showDialog();
    }
    </script>
</head>
<body>
    <h3>PhoneGap-GoogleMaps-Plugin</h3>
    <div style="width:100%;height:400px" id="map_canvas"></div>
    <button id="button">Full Screen</button>
</body>
</html>

这是插件googlemap-plugin以下代码有什么问题?我该怎么解决?请帮我 . 谢谢 .

1 回答

  • 0

    Cordova在WebViews中进行了大量渲染,而不是在Android的View API中进行本地渲染 . 您生成的API密钥严格用于“Android应用” . 由于您未使用Android Google Maps API,因此我建议您尝试将密钥限制为“HTTP引用”,甚至使用“无”进行测试

相关问题