Ruby on rails 轨道&x2B;谷歌地图,显示多个标记

Ruby on rails 轨道&x2B;谷歌地图,显示多个标记,ruby-on-rails,google-maps,google-maps-markers,Ruby On Rails,Google Maps,Google Maps Markers,我需要在Rails应用程序中显示用户的位置,我使用了以下代码,它运行良好: function showLocations(){ <% if @profile.location.latitude.nil? || @profile.location.longitude.nil? %> canvas = $('#map_canvas'); canvas.html("<h1>The user have not specified his location y

我需要在Rails应用程序中显示用户的位置,我使用了以下代码,它运行良好:

function showLocations(){
    <% if @profile.location.latitude.nil? || @profile.location.longitude.nil? %>

   canvas = $('#map_canvas');
   canvas.html("<h1>The user have not specified his location yet</h1>")
   canvas.slideDown();

<%else%>
var latlng = new google.maps.LatLng(<%=@profile.location.latitude%>, <%=@profile.location.longitude%>);
var myOptions = {
  zoom: 12,
  center: latlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};
var canvas = document.getElementById("map_canvas")
var map = new google.maps.Map(canvas,
myOptions);

var marker = new google.maps.Marker({
  position: latlng,
  title:"<%=@profile.full_name%>"
  });

  marker.setMap(map);



  <%end%>

  $('#map_canvas').slideDown('slow');

}
函数showLocations(){
画布=$('map_canvas');
html(“用户尚未指定其位置”)
canvas.slideDown();
var latlng=新的google.maps.latlng(,);
变量myOptions={
缩放:12,
中心:拉特林,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
var canvas=document.getElementById(“映射画布”)
var map=new google.maps.map(画布,
肌肽);
var marker=new google.maps.marker({
位置:latlng,
标题:“
});
marker.setMap(map);
$('map_canvas')。向下滑动('slideDown');
}
现在,我想获取一个用户数组,并在地图上显示多个标记,因此假设我不再有@profile,而是@profile_数组,并且每个用户都必须在地图上用一个标记表示。您认为如何更改上述代码以实现我的目标?

Tnx

为什么不使用我的gem
gmaps4rails