(“橙众议院的icon.png”), “width”=&gt; 50, “height”=&gt; 50 }) marker.infowindow render_to_string(partial:‘layouts / MapInfo的 </跨度> ’,locals:{property:property.id}) marker.title“我是标题”结束结束
鈥
你可以这样做:
@hash = Gmaps4rails.build_markers(@properties) do |property, marker| marker.lat property.latitude marker.lng property.longitude marker.picture({ "url" => view_context.image_path("Orange-House-Icon.png"), "width" => 50, "height" => 50 }) marker.infowindow render_to_string( partial: 'layouts/mapinfo', locals: { property: property.id }) marker.title "i'm the title" end if @hash.empty? @hash.push({ lat: current_user.latitude, lng: current_user.longitude }) end
顺便说一句,重命名会很棒 @hash 至 @array
@hash
@array