Google Maps Multiple markers with the exact same location Not working

Solution 1:

You need to :

  1. create the marker clusterer first.
  2. add the markers to the MarkerClusterer (and format your code so it is easier to read...).

    function createMarker(latlng,text) {
      var marker = new google.maps.Marker({
        position: latlng,
        map: map
      });
    
      ///get array of markers currently in cluster
      var allMarkers = mc.getMarkers();
    
      //check to see if any of the existing markers match the latlng of the new marker
      if (allMarkers.length != 0) {
        for (i=0; i < allMarkers.length; i++) {
          var existingMarker = allMarkers[i];
          var pos = existingMarker.getPosition();
    
          if (latlng.equals(pos)) {
            text = text + " & " + content[i];
          }                   
        }
      }
    
      google.maps.event.addListener(marker, 'click', function() {
        infowindow.close();
        infowindow.setContent(text);
        infowindow.open(map,marker);
      });
      mc.addMarker(marker);
      return marker;
    }
    

working example