mina morsali
mina morsali

Reputation: 778

using google map plugin with cordova show blank map

I want to use google map plugin in my cordova app. I Create Successfully my sha1 key with following command:

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

and I create my android and IOS Key successfully. package name , sha1 ,... import correctly :

enter image description here

but when I build my app with following index.html page , I see a blank map with only google icon :

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>

here is the plugin googlemap-plugin What is wrong with following code? how can I fix it? please help me. thank you.

Upvotes: 0

Views: 748

Answers (1)

thomaspsk
thomaspsk

Reputation: 789

Cordova does a lot of rendering in WebViews instead of natively in Android's View API. Your API key you generated is strictly for "Android apps". 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"

Upvotes: 0

Related Questions