簡體   English   中英

Rails上的jQuery-ui-map插件:地圖沒有響應(無法移動或縮放等)

[英]jQuery-ui-map plugin on Rails: Map is not responding (can't move or zoom etc.)

此html示例正常運行。 它加載地圖,並且可以移動,縮放等。

<!DOCTYPE html>
<html>
<head>
  <script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript"></script>
  <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js" type="text/javascript" ></script>
  <script src="C:\Sites\MyApp\app\assets\javascripts\mobile\jquery.ui.map.full.min.js" type="text/javascript"></script>
</head>

<body>
  <script>
    $(function() {
      $('#map_canvas').gmap();
    });
  </script>

<div id="map_canvas" style="width:250px;height:250px"></div>

</body>
</html>

但是,當我將其放入我的Ruby on Rails應用程序中時(只有第4個腳本路徑有所不同):

<!DOCTYPE html>
<html>
<head>
  <script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript"></script>
  <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js" type="text/javascript" ></script>
  <script src="assets\mobile\jquery.ui.map.full.min.js" type="text/javascript"></script>
</head>

<body>
  <script>
    $(function() {
      $('#map_canvas').gmap();
    });
  </script>

  <div id="map_canvas" style="width:250px;height:250px"></div>

</body>
</html>

地圖不再可移動。 就像靜態圖片一樣。 每個js文件都會被加載,並且所有文件都一樣,除了“ jquery.ui.map.full.min.js”文件路徑發生了變化。 兩種情況下都正確加載了該文件,唯一的區別是,在Rails情況下,文件末尾有一個額外的空行和一個額外的分號(;)。

怎么了? 有人成功組合了jquery-ui-map插件和ruby on rails嗎? 任何想法導致這種奇怪?

我正在使用jquery-ui-map-3.0-rc Rails 3.2.3

嘗試使用http://jsbeautifier.org/縮小jquery.ui.map.full.min.js

然后將jquery.ui.map.full.min.js重命名為map.js

以這種方式為我工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM