Tag: gmaps4rails

谷歌地图,Rails和Jquery

更新7/17已解决 我已将我的代码更新为Solved版本。 原始问题 我正试图通过Gem gmaps4rails显示谷歌地图。 在研究了此处和此处发布的以下2个问题之后,Google地图似乎存在一个问题,该选项卡隐藏并显示来自Jquery或Javascript的内容,并且如果没有Jquery中的某些代码,则无法正确显示Google Map。 我坚持在我的JavaScript中调整地图大小可以有人指出我的错误? 谢谢! 我的代码: 使用Javascript $(document).ready(function(){ //Default Action $(“.gear_tab_content”).hide(); //Hide all content $(“ul.gear_page_tabs li:first”).addClass(“active”).show(); //Activate first tab $(“.gear_tab_content:first”).show(); //Show first tab content $(“.map_container”).hide(); //Hide the Google Map //On Click Event $(“ul.gear_page_tabs li”).click(function() { $(“ul.gear_page_tabs li”).removeClass(“active”); //Remove any “active” class $(this).addClass(“active”); //Add “active” class to selected tab $(“.gear_tab_content”).hide(); //Hide all […]

Gmaps4rails循环遍历数组

我有一个包含30多个位置的数组,我想在地图上显示。 但是,我没有找到一个演示如何遍历数组以使标记出现在地图上的源,而是选择严格硬编码地图lat / long值。 例如,这是我目前的代码,但它返回错误: allLocations = root.table.rows().data() root.forMap = [] for aLocation in allLocations root.forMap.push(aLocation[9] + ‘, ‘ + aLocation[10]) $(‘#multi_markers’).map -> handler = Gmaps.build(“Google”) handler.buildMap internal: id: “multi_markers” , -> markers = handler.addMarkers(root.forMap) handler.bounds.extendWith markers handler.fitMapToBounds() 注意:我不能简单地使用ruby方法,因为该表还必须与.js.coffee文件中的DataTable数据进行交互。 如何在gmaps4rails方法中循环遍历数组?

Gmaps4rails:动态加载时地图未显示

当我通过Jquery调用( $(‘#id’).load(/xyz) )使用Gmaps4rails显示地图时,不会显示地图(而是显示空白区域)。 此页面: https : map.reloadMap ?hl= map.reloadMap建议在页面加载后调用map.reloadMap ,但我不知道应该调用的元素的id。 gmaps4rails文档仅提到包含地图的div的id,并且阅读源代码没有帮助。 怎么解决这个问题?