Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我认为我不需要从我的应用程序中发布特定代码。简单来说,我有一个带有名称、地址、经度、纬度、gmaps 的数据库表。每条记录存储一个位置。好的。当我加载页面时,谷歌地图刚从大西洋中间开始,我想知道有没有办法让它从我桌子上已经有的一个位置开始?
嘿,当您将记录传递给视图时,您可以使用它来使地图居中。
<%= gmaps({ "map_options" => { "auto_adjust" => false, "center_longitude" => @record.long, "center_latitude" => @record.lat, "auto_zoom" => false, "zoom" => 5 }, "markers" => {"data" => @json } }) %>
当您尝试此操作时,请确保您已设置auto_adjust为false.
auto_adjust
false