【发布时间】:2015-02-10 21:52:21
【问题描述】:
我已经更改了我的模型和控制器名称以及所有连接的数据 + 文件名。一切正常,除了我的 JS GoogleMaps API 大喊:
TypeError: this.clusterer is undefined
问题是 - 我再次尝试预编译我的资产,我搜索了所有文件,但找不到答案。 您知道 rake 持有/更改的所有资产在哪里,我应该在哪里寻找答案?
我的控制器:
def index
@hunts = Hunt.all
@hash = Gmaps4rails.build_markers(@hunts) do |hunt, marker|
marker.lat hunt.latitude
marker.lng hunt.longitude
marker.infowindow hunt.email
end
end
查看:
<script src="//maps.google.com/maps/api/js?v=3.13&sensor=false&libraries=geometry" type="text/javascript"></script>
<script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js' type='text/javascript'></script>
<%= javascript_include_tag 'hunt_map'%>
还有 JS:
handler = Gmaps.build('Google');
handler.buildMap(
{
provider: {
center: new google.maps.LatLng(50.0636153, 19.9317813),
zoom: 13
},
internal: { id: 'map' }
},
function(){
markers = handler.addMarkers(<%=raw @hash.to_json %>);
handler.fitMapToBounds();
handler.addCircles(
[{ lat: 50.0636153, lng: 19.9317813, radius: 5}],
{ strokeColor: "#000" });
});
handler.addMarkers([
{
"lat": 50.0636153,
"lng": 19.9317813,
"picture": {
"url": "http://www.tamu.edu/faculty/ccbn/dewitt/adp/resources/images/shamrock.gif",
"width": 36,
"height": 36
},
"infowindow": "Treasure lies here!"
}
]);
更新: 我的 config/initializers/assets.rb
Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.precompile += %w( hunt_map.js )
【问题讨论】:
标签: javascript ruby-on-rails google-maps markerclusterer