带有gmaps4rails的谷歌地图中的不同标记
问题描述:
使用gmaps4rails有一种方法define a custom marker。但是每个数据库条目都会显示相同的内容。带有gmaps4rails的谷歌地图中的不同标记
如何为每个数据库条目显示不同的标记,例如Google谷歌纵横?最好通过他们自己的数据库列或通过精灵,如果只有类别/组的图片而不是单个用户。
答
大厦apneadivings答案,二可能更短的方式浮现在脑海中:
通用:
def gmaps4rails_marker_picture
{
"picture" => self.image_path, # image_path column has to contain something like '/assets/my_pic.jpg'.
"width" => 32, #beware to resize your pictures properly
"height" => 32 #beware to resize your pictures properly
}
end
在这种情况下,我们重用类列名的画面:
def gmaps4rails_marker_picture
{
"picture" => "/images/" + self.category + ".png",
"width" => 32, #beware to resize your pictures properly
"height" => 32 #beware to resize your pictures properly
}
end
现在唯一缺少的东西是使用精灵的方法。但那可能不可能。
干得好jmk;) – apneadiving 2011-02-18 19:42:22