在索引操作中工作时一切正常,但是当我尝试在显示视图中显示地图时,它不能很好地显示。
控制器.rb:
def show
@person = Person.find(params[:id])
@json = Person.find(params[:id]).to_gmaps4rails
respond_to do |format|
format.html # show.html.erb
format.json { render json: @person }
end
end
显示.html.erb:
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a href="#profile" data-toggle="tab">Profile</a></li>
<li><a href="#places" data-toggle="tab">Places</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade active in" id="profile">
Some text here...
</div>
<div class="tab-pane fade" id="places">
<%= gmaps(:map_options => {:type => "ROADMAP"},
:markers => {:data => @json,
:options => {"list_container" => "markers_list" }}) %>
</div>
</div>
</div>
模型.rb:
acts_as_gmappable
def gmaps4rails_address
address
end
def gmaps4rails_infowindow
"<h3><img src=\"#{self.avatar(:thumb)}\"> #{ERB::Util.json_escape name.humanize}</h3>
<hr/>
<h4>#{ERB::Util.json_escape address.humanize}</h4>"
end
def gmaps4rails_sidebar
"<span>#{name.humanize}</span>" #put whatever you want here
end
有任何想法吗?这是屏幕截图的链接: http: //cl.ly/2x2H002e3O0P1w0R0b3K