title: Google map api v3 add polylines from array
body: <p>I'm trying to add a set of poly lines to a google map from an array.  </p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no" /&gt;
  
  &lt;style type="text/css"&gt;
    html { height: 90% }
    body { height: 90%; margin: 0; padding: 0 }
    #map_canvas { height: 100% }
  &lt;/style&gt;
  &lt;script type="text/javascript"
      src="http://maps.googleapis.com/maps/api/js?sensor=false"&gt;
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  var poly;
  var map;
    function initialize() {
      var latlng = new google.maps.LatLng(38.698044, -77.210411);
      var myOptions = {
        zoom: 8,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
  
  
       //var myLatLng = new google.maps.LatLng(0, -180);
    }
  
  
    var polyOptions = {
      strokeColor: '#000000',
      strokeOpacity: 1.0,
      strokeWeight: 3
    }
    poly = new google.maps.Polyline(polyOptions);
    poly.setMap(map);
  
  var path = new MVCArray;
  
  $.getJSON('json.php', function(data) {
    //var items = [];
    $.each(data, function(key, val) {
  
  
    path.push(new google.maps.LatLng(val.lat, val.longi));
  
    });
  
  });
  
  
  
    var myOptions = {
      zoom: 12,
      //center: myLatLng,
      mapTypeId: google.maps.MapTypeId.TERRAIN
    };
  
  &lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"&gt;&lt;/script&gt;
  
  
  
  
  
  
  
  
  &lt;/head&gt;
  
  &lt;body onload="initialize()"&gt;
    &lt;div id="map_canvas" style="width:90%; height:100%"&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any thoughts on why the line path.push(new google.maps.LatLng(val.lat, val.longi)); isn't adding the data in?</p>
  
  <p>Or is there a better way for me to loop the data in?</p>