2012-07-12 58 views
0

我嘗試了許多不同的例子使用jquery-ui-map jquery插件,但沒有幸運。204沒有內容jquery-ui-map,一個jQuery的谷歌地圖v3插件

這是簡單的代碼

<!DOCTYPE HTML> 
<html> 

<head> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
    <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script> 
    <script type="text/javascript" src="js/jquery.ui.map.js"></script> 
    <script type="text/javascript" src="js/jquery.ui.map.services.js"></script> 
    <script type="text/javascript" charset="utf-8" src="jquery-1.7.1.min.js"></script> 
    <script> 
     function init() { 
      $('#map_canvas').gmap({ 'center': '42.345573,-71.098326' }); 
     }; 
    </script> 
</head> 

<body onload="init();"> 
    <div id="map_canvas" style="width:100%; height:100%"></div> 
</body> 

</html> 

它的推出很好,在螢火控制檯的腳本,每次顯示我:

網址:GET「https://maps.googleapis.com/maps ?/ gen_204 EV = api_ads & CAD =源:apiv3,廣告:0" 狀態:204無內容

我的第一印象是我不使用的API KEY,但在谷歌文檔說,「不強制使用KEY「。

有什麼想法?

在此先感謝。

回答

0

這是一個工作示例。您應該只改變路徑的jQuery和jQuery UI的地圖:

<!DOCTYPE HTML> 
<html> 
    <head> 
     <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
     <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
     <script type="text/javascript" src="js/jquery/jquery.min.js"></script> 
     <script type="text/javascript" src="js/jquery/jquery.ui.map.full.min.js"></script> 
     <script> 
      function init() { 
       $('#map_canvas').gmap({ 'center': '42.345573,-71.098326' }); 
      }; 
     </script> 
    </head> 

    <body onload="init();"> 
     <div id="map_canvas" style="width:100%;height:350px;"></div> 
    </body>  
</html> 

你的錯誤似乎是以下幾點:

  1. 您必須包括jQuery的前UI,地圖插件
  2. map_canvas「 s風格的高度應該在px。
  3. 你應該得到的API通過http而不是https