0
我目前使用paperclip gem上傳用戶profile_image。我還使用gmaps4rails顯示用戶位置和標記信息的谷歌地圖。一切正常,但我不知道如何上傳用戶的profile_image標記。下面是我有:如何使用回形針將圖像上傳到Gmaps4rails的標記?
中的正常用戶視圖頁面下面的代碼顯示用戶的個人資料圖片:
<%= image_tag user.profile_image.url(:thumb)%>
我嘗試使用上面的代碼中的控制器,但它似乎沒有工作
用戶控制器:
@hash = Gmaps4rails.build_markers(@nearby) do |user, marker|
marker.lat user.latitude
marker.lng user.longitude
marker.infowindow user.name
marker.picture({
"url" => "<%=image_tag user.profile_pic.url(:thumb)%>",
"width" => 36,
"height" => 36
})
end
後我加入了marker.picture地圖仍然存在,只是在標記有在用戶的視線中消失
:
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map'}},
function(){
markers = handler.addMarkers(<%=raw @hash.to_json %>);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
任何建議/解決方案,或者如果你可以點我到正確的方向將不勝感激!
感謝,現在的工作! –