I need to show the position of an user inside my Rails application, I used the following code and it works well:
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 mark开发者_如何学Cer = new google.maps.Marker({
position: latlng,
title:"<%=@profile.full_name%>"
});
marker.setMap(map);
<%end%>
$('#map_canvas').slideDown('slow');
}
Now, I want to take an Array of users and show mutiple marker on the map, so suppose that I no longer have @profile but @profile_array, and each of them have to be represented by a marker on the map. How do you think could I change the code above in order to achieve what I want ?
Tnx
精彩评论