def home
letter = 'A'
@markers = Location.all.to_gmaps4rails do |loc, marker|
marker.infowindow render_to_string(partial: '/locations/info',
locals: {object: loc})
marker.picture({picture: "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=#{letter.next!}|9966FF|000000",
width: 32,
height: 32,
shadow_picture: "http://chart.apis.google.com/chart?chst=d_map_pin_shadow",
shadow_width: 110,
shadow_height: 110,
shadow_anchor: [17,36]})
marker.title "Title - #{loc.name}"
marker.sidebar render_to_string(partial: '/locations/sidebar',
locals: {object: loc})
marker.json({id: loc.id})
end
end
酷的东西。所以这行得通。它循环遍历do loop
并增加字母。问题是,它从 B 开始。我尝试letter
在图片中使用,然后在最后使用letter.next!
,甚至letter = letter.next
,但是 gmaps 向我抛出错误。
有没有办法将除“A”之外的东西分配给letter
?