2014-02-11 121 views
0

只是我想要一個谷歌地圖工作科爾多瓦安卓的最小例子。 該代碼在Chrome和Firefox的本地主機上正常工作,但我無法在設備上工作。科爾多瓦3.3安卓和谷歌地圖,鉻錯誤

示例代碼:

<!DOCTYPE html> 
<html> 
    <head> 
     <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script> 
     <script type='text/javascript'> 
      window.addEventListener('deviceready',function(){ 
       var latitud = xx.xxxxxxx; 
       var longitud = x.xxxxxxxxxxxxxxxx; 
       success(latitud,longitud); 
      },true); 

      function success(latitud,longitud) { 
       var coords = new google.maps.LatLng(latitud, longitud); 

       var options = { 
       zoom: 15, 
       center: coords, 
       mapTypeControl: false, 
       navigationControlOptions: { 
        style: google.maps.NavigationControlStyle.SMALL 
       }, 
       mapTypeId: google.maps.MapTypeId.ROADMAP 
       }; 
       var map = new google.maps.Map(document.getElementById("prova_maps"), options); 

       var marker = new google.maps.Marker({ 
        position: coords, 
        map: map, 
        title:"You are here!" 
       }); 
      } 
     </script> 
    </head> 
    <body> 
     <h1>Google Maps</h1> 
     <div id='prova_maps' style='height:250px;width:250px;'></div> 

    </body> 
</html> 

我在控制檯以下錯誤直接與這一問題重新啓動,但無法找到一個解決方案:

https://imageshack.com/i/f3myppp

我有在config.xml中添加訪問標籤。

回答

1

甚至嘗試添加

而且index.html中

<script type="text/javascript" src="../platform/js/libs/cordova.js"></script> 

嘗試添加腳本中的鏈接...標籤

google.maps.event.addDomListener (窗口,'加載',初始化);

+0

現在隨着cordova js標籤最後工作的感謝之人!!!! – Xdevelop

+0

像在登錄貓,你正在得到什麼是恐怖.. –

+0

這是否解決了你的問題.... –