title: Adding markers from an array into Leaflet
body: <p>I am trying to add markers from an array into a leaflet map. I am trying to get the popup info, layer and coordinates from the array. I must be missing something obvious because I can't pull the layer info.</p>
  
  <p>markersArray[i][1] returns the value "layer1" but it does not work in the .addTo method.</p>
  
  <p>EDIT: I HAVE CHANGED THE CODE TO SOLVE A PROBLEM WITH A MARKER APPEARING OUTSIDE THE CLUSTER:</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>var markersList = [];
  var markersList = [
  [41.15,-8.61,'popup1','layer1'],
  [41.15,-8.61,'popup2','layer1'],
  [41.15,-8.31,'popup3','layer2'],
  [41.15,-8.31,'popup4','layer2']
  ];
  
  var markers = new L.MarkerClusterGroup();
  
  for (var i = 0; i &lt; markersList.length; i++) {
  markers.addLayer(new L.marker([markersList[i][0], markersList[i][1]]).bindPopup(markersList[i][2]));
  markers.addTo(layer1); // working
  markers.addTo(markersList[i][3]); // not working
  map.addLayer(markers);
  };
  </code></pre>
  
  <p>Thanks for helping.</p>