I am trying to add a google map to my application following the code present on this page.
http://iheartmyyogi.com/map.html
here is the script I have, I made some changes for it to fit my needs...
<script type="text/javascript"> var infowindow = null; $(document).ready(function () { initialize(); });
function initialize() { var centerMap = new google.maps.LatLng(29.606880689139555, 69.53661557617194); var myOptions = { zoom: 5, center: centerMap, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); setMarkers(map, sites); infowindow = new google.maps.InfoWindow({ content: "loading..." }); }
var sites = [ ['Mount Evans', 39.58108, -105.63535, 4, 'This is Mount Evans.'], ['Irving Homestead', 40.315939, -105.440630, 2, 'This is the Irving Homestead.'], ['Badlands National Park', 43.785890, -101.90175, 1, 'This is Badlands National Park'], ['Flatirons in the Spring', 39.99948, -105.28370, 3, 'These are the Flatirons in the spring.'] ];
function setMarkers(map, markers) { for (var i = 0; i < markers.length; i++) { var sites = markers[i]; var siteLatLng = new google.maps.LatLng(sites[1]); var marker = new google.maps.Marker({ position: siteLatLng, map: map, title: sites[0], zIndex: sites[2], });
var contentString = "Some content"; google.maps.event.addListener(marker, "click", function () { infowindow.setContent(this.html); infowindow.open(map, this); }); } } </script>
In my table I have the following data
:Name, :ll_value, :id,
I am wondering how I can use ruby to return an array simillar to what the original author is using in var sites?
I also tried returning json but the json returned is all html escaped so i am not sure how i can use that in the javascript.