2016-01-12 29 views
1

我正在使用Visual Studio 2013 Apache Cordova應用程序。我在Google地圖上找到一個點時遇到問題。我在我的應用中添加了地理位置插件,但它不起作用。這裏是我的代碼:GoogleMaps不會在我的科爾多瓦應用程序中運行

<!DOCTYPE html> 
<html> 
<head> 
    <title></title> 
</head> 
<body> 
    <div><button id="showmap" >show map </button></div> 
    <div id="googleMap">View Map ---</div> 
    <script src="cordova.js"></script> 
    <script src="scripts/platformOverrides.js"></script> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script> 
    <script src="http://maps.googleapis.com/maps/api/js"></script> 

    <script> 

     $("#showmap").click(function() { 
      var damas = new google.maps.LatLng(33.513, 36.2920000000003); 
      var mapProp = { 
       center: damas, 
       zoom: 8, 
       mapTypeId: google.maps.MapTypeId.ROADMAP 
      }; 

      var map = new google.maps.Map(document.getElementById("googleMap"), mapProp); 
      var myCity = new google.maps.Circle({ 
       center: damas, 
       radius: 20000, 
       strokeColor: "#0F00FF", 
       strokeOpacity: 0.8, 
       strokeWeight: 2, 
       fillColor: "#F0F0FF", 
       fillOpacity: 0.8, 
       editable: true 
      }); 

      myCity.setMap(map); 
     }); 
    </script> 
</body> 

</html> 

請給我一些建議。謝謝!

+0

你有沒有試圖爲你的'googleMap' div設置一個維度? – erikscandola

回答

1

您需要高度添加到您的div:

<div id="googleMap" style="height:300px;">View Map ---</div> 

或者,如果你願意,你可以設置它,當你點擊顯示地圖按鈕:

$("#googleMap").height(300); 

Here你可以看到一個例子我爲你創造。

+0

是的它的工作,我忘了添加樣式到我的分區。非常感謝你 。 – prime

相關問題