title: Adding map markers with php, javascript and json
body: <p>Trying to add markers from mysql by retrieving them using php and then json_encode()to then use the results in javascript. Currently I the map is displaying for me, but the markers are not!</p>
  
  <p>MarkersController.php - fetching information from database.</p>
  
  <pre><code>$list = array();
  
  while ($row = mysqli_fetch_assoc($result)) {
      $list[] = array(
          array('lat' =&gt; $lat), 
          array('lng' =&gt; $lng));
  }
  echo json_encode($list);
  </code></pre>
  
  <p>Landing.html</p>
  
  <pre><code>&lt;script type="text/javascript" src="js/jquery-1.11.2.js"&gt;&lt;/script&gt;
                      &lt;script type = "text/javascript"
                              src = "https://maps.googleapis.com/maps/api/js?
                              key=AIzaSyB76xBqfQdgOLV77VK3JZ09vWwk8brkMFs"&gt;
                      &lt;/script&gt;
                      &lt;script type="text/javascript"&gt;
                                  var map = null;
                                  function addMarker(lat, lng) {
                                  var myLatLng = new google.maps.LatLng(lat, lng);
                                          marker = new google.maps.Marker({
                                          position: myLatLng,
                                                  map: map
                                          });
                                  }
  
  
                          function initialize() {
                          var mapOptions = {
                          center: {lat: 54.872128, lng: - 6.284874},
                                  zoom: 13
                          };
    map = new google.maps.Map(document.getElementById('map-canvas'),
                                          mapOptions);
  
          $.getJSON('MarkersController.php', function(data){
                                  $.each(data, function(lat, lng){
                                  addMarker('lat', 'lng');
                                  });
                                  })
                              }
            google.maps.event.addDomListener(window, 'load', initialize);
  
                      &lt;/script&gt;
  </code></pre>
  
  <p>Trying to use the array from MarkersController.php to implement the addMarker() function.</p>