Gmaps4rails:设置地图宽度和高度
阅读gmaps4rails gem文档,我没有找到任何设置地图宽度和高度的方法。 有没有办法做到这一点?
我应该进一步详细说明。
我将做一个安装rake任务来复制Rails应用程序中的css和javascript。
好吧,现在,只需在你的css中覆盖它(我假设你没有改变地图ID)。
#gmaps4rails_map { width: 800px; height: 400px; }
如果你想让它工作,请注意在yield(:head)
后包括你的css yield(:head)
<%= yield :head %> <%= stylesheet_link_tag "your css" %>
@apenadving的答案对我不起作用,假设地图div类和id没有改变,我需要做以下(在scss中)以使事情正常工作,也许我错过了一些东西。 ..
.map_container{ $width:675px; width:$width; .gmaps4rails_map{ width: $width; height: 400px; } }
使用rails 3.1及更高版本,您只需在application.css.scss
文件中执行以下操作即可
@import "gmaps4rails"; @import "myCoolStyle";
如果你想这么做我会建议你按照这套步骤:
使用以下命令添加自定义容器类
<%= gmaps( :map_options => { :container_class => "map_container_renamed" }, "markers" => {"data" => @json, "options" => {"auto_zoom" => false} }) %>
然后添加你的CSS:
div.map_container_renamed #map { width: 420px; height: 260px; } div.map_container_renamed { padding: 6px; border-width: 1px; border-style: solid; border-color: #ccc #ccc #999 #ccc; -webkit-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px; -moz-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px; box-shadow: rgba(64, 64, 64, 0.1) 0 2px 5px; width: 420px; }