简体   繁体   English

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

[英]using google map plugin with cordova show blank map

I want to use google map plugin in my cordova app. 我想在我的cordova应用中使用google map插件。 I Create Successfully my sha1 key with following command: 我使用以下命令成功创建了sha1键:

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

and I create my android and IOS Key successfully. 并且我成功创建了android和IOS Key。 package name , sha1 ,... import correctly : 包名称,sha1,...正确导入:

在此处输入图片说明

but when I build my app with following index.html page , I see a blank map with only google icon : 但是当我使用以下index.html页面构建应用程序时,我看到只有Google图标的空白地图:

在此处输入图片说明

    <!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>

here is the plugin googlemap-plugin What is wrong with following code? 这是插件googlemap-plugin以下代码有什么问题? how can I fix it? 我该如何解决? please help me. 请帮我。 thank you. 谢谢。

Cordova does a lot of rendering in WebViews instead of natively in Android's View API. Cordova在WebViews中进行了大量渲染,而不是在Android的View API中进行本地渲染。 Your API key you generated is strictly for "Android apps". 您生成的API密钥严格用于“ Android应用”。 Since you are not using the Android Google Maps API, I suggest you try restricting your key to "HTTP referrers" or even testing with "None" 由于您未使用Android Google Maps API,因此建议您尝试将密钥限制为“ HTTP Referrers”,甚至使用“ None”进行测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM