Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I built a map using Leaflet and markercluster.js, and I'm having a strange issue where after I click on the first popup, I'm unable to open any other popup. This happens whether you close the first popup manually or not.

When I don't use markercluster.js, the popups appear as normal, so I know it has something to do with that library. This is the second time I have used this library; the first time I had no issues. I'm getting no errors in the console.

Also, I had this issue regardless of if the .openPopup() method was attached to the marker variable.

Code below:

var puetrasList = new L.MarkerClusterGroup();

          for (i=0 ; i < dataStore.length ; i++){
              var a, point;
              a = dataStore[i];
              lat = parseFloat(dataStore[i][0]);
              lng = parseFloat(dataStore[i][1]);
              title = "<strong><h2>" + dataStore[i][2] + "</strong></h2>" +
                                  "<p>" + >dataStore[i][3] + "</p>" +
                                  "<p>" + >dataStore[i][4] + ", " + dataStore[i][5] + "</p>" +
                                  "<p>" + >dataStore[i][6] + "</p>";
              marker = new L.Marker(new L.LatLng(lat, lng));
              marker.bindPopup(title).openPopup();
              console.log(marker)
              puetrasList.addLayer(marker);
          }



          //----- Summon Map ---->
          map.addLayer(puetrasList);
          map.addLayer(layer);
share|improve this question
    
map.addLayer(layer); what is layer? –  LSA Jun 4 '13 at 20:53

1 Answer 1

Use marker on click in the for loop.It will shows the popup

 marker.on('click', function (e) {              
    this.bindPopup(title); 

});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.