你如何通过部分自定义gmaps4rails中的标记图片和infowindow?

时间:2013-06-09 15:35:58

标签: gmaps4rails

类VenuesController< ApplicationController中

def index

@search = Venue.search(params[:search])
@venues = @search.all(:order => "name ASC")
@json = @search.all.to_gmaps4rails do |venue, marker|

marker.infowindow render_to_string(:partial =>“info”,:locals => {:object => venue})     marker.picture({                   :picture => “图像/#{name}的巴纽”                   :width => 32,                   :height => 32                  })

respond_to do |format|
  format.html # index.html.erb
  format.json { render json: @venues }
end

1 个答案:

答案 0 :(得分:0)

您的部分不起作用,因为它需要名为venue的变量。

在您的控制器中,尝试将您的本地哈希值更改为:locals => { :venue => venue }

marker.infowindow render_to_string(
  :partial => "info", 
  :locals => { 
    :venue => venue 
  }
) 
marker.picture({
  :picture => "images/#{name}.png", 
  :width => 32, 
  :height => 32 
})

对于您的标记图片,您的错误是什么?

第h