I'm trying to dynamically draw a Google Map and place a marker on it. In my controller, I assemble an array containing the name of the businesss, latitude, longitude and a z-index.
I have an array in Ruby that is available to my Rails view:
@locations = [["Location One",36.0552,-114.928,1]]
When I try to use that array in some Javascript:
var loc = <%= @locations %>
I see this in view source:
var loc = [["Location One",36.0552,-114.928,1]]
In order for the map to display the variable needs to read like:
var loc = [['Location One',36.0552,-114.928,1]]
With the quotes intact around the first element of the array. If I hard code that last line into the Javascript the map renders correctly. It really seems to be the quot; tags that are messing things up.
There will be more than one location on the map so I thought an array of arrays would be the best way to get the needed data into my view.
How can I accomplish this? Thanks.