title: Why Google Map Multiple marker 'For loop' not work?
body: <p>I try to add multiple marker.Data get from database and pass to 'initMap' function,then Map and marker are show correctly but the problem is <strong>for loop is not working properly</strong>.I <strong>have two location but only show one location (last location)</strong>.</p>
  
  <p><a href="https://i.stack.imgur.com/8p0DY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8p0DY.png" alt="This is view of now"></a></p>
  
  <pre><code>function initMap(post_obj) {
      //*** json object convert to JS array
              var columns = ['longitude', 'latitude', 'placeName', 'phoneNo'];
      var locations = JSON.parse(post_obj).map(function(obj) {
        return columns.map(function(key) {
          return obj[key];
        });
      });
  
      var mapProp= {
          center:new google.maps.LatLng(7.8731,80.7718), //locate Sri Lanka
          zoom:7,
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          styles: [{
              featureType: 'all',
              stylers: [
                  {saturation: -100}, //Grey Color map
                  {gamma: 0.50},
              ]
  
          }]
      };
      var map = new google.maps.Map(document.getElementById("map_canvas"),mapProp);
  
       var marker, i;
       var infowindow = new google.maps.InfoWindow();
  
      for (i = 0; i &lt; locations.length; i++) {  
          console.log(locations[i][0]);
        marker = new google.maps.Marker({
          position: new google.maps.LatLng(locations[i][0], locations[i][1]),
          map: map
        });
  
        google.maps.event.addListener(marker, 'click', (function(marker, i) {
          return function() {
            infowindow.setContent(locations[i][0]);
            infowindow.open(map, marker);
          }
        })(marker, i));
      }
  
  }
  </code></pre>
  
  <p>' post_obj ' looks like</p>
  
  <pre><code>[{"longitude":"79.92094122685603","latitude":"6.858206289512469","placeName":"refill Place Rika's","phoneNo":""},{"longitude":"6.534608320452274","latitude":"81.19367459766863","placeName":"","phoneNo":""}]
  </code></pre>
  
  <p>Please help me find solution.</p>