[GIS] Leaflet Marker Cluster not appearing

leaflet

I would like for my points to cluster using L.markerClusterGroup.

I am receiving a 200 status; but nothing appears on my map. I have commented out my markers which appear when uncommented.

http://jsfiddle.net/8mnyqx49/

/// var points = L.geoJson(geojsonfeatures, {
    ///filter: function(feature, layer) {
       /// return feature.properties.COUNTRY != "UNITED STATES";
  ///  },
   /// pointToLayer: function(feature, latLng) {
       ///  return L.marker(latLng)
         ///  .bindPopup(feature.properties.NAME);

var points = L.markerClusterGroup();

for (var i = 0; i < geojsonfeatures.length; i++) {
  var a = geojsonfeatures[i];
  var NAME = a[2];
  var marker = L.marker(new L.LatLng(a[0], a[1]), { NAME: NAME });
  marker.bindPopup(NAME);
  markers.addLayer(NAME);
}

map = L.map('myMap', {
  center: centerlatlng,
  zoom: 6,
  layers: [aLayerOne]
});

Best Answer

As far as I can see, you not seeing anything, because you're not adding your GeoJSON layer to the markerClusterGroup.

According to the instructions, the following steps are needed:

var markers = new L.MarkerClusterGroup();
markers.addLayer(new L.Marker(getRandomLatLng(map)));
map.addLayer(markers);

Translated to your case, I would try something along the following lines (Unfortunately I couldn't find your geojsonfeatures stream or file anywhere, so I can't be more specific...)

// Define markerClusterGroup
var pointsCluster = L.markerClusterGroup();

// Build your GeoJSON layer
// I  assumed this part worked for you, so I only uncommented it
var points = L.geoJson(geojsonfeatures, {
    filter: function(feature, layer) {
       return feature.properties.COUNTRY != "UNITED STATES";
    },
    pointToLayer: function(feature, latLng) {
       return L.marker(latLng)
         .bindPopup(feature.properties.NAME);
    }
}

// Add your GeoJSON layer to the MarkerClusterGroup
pointsCluster.addLayer(points);

// Add your MarkerClusterGroup to the map
map.addLayer(pointsCluster);