Im new to coding and Im trying to bind popups to markers on a map. I have various markers already on the map and have attempted to bind the popups. The issue I am having is when I click on various markers the popup information is all the same. The content of each popup doesn't change when you click on different markers. Each marker needs to have its own content. Any ideas on how to achieve this?

This is the js code I am currently using:

// Surf Brewery
    L.marker([34.257845, -119.231165], {icon: beer}).addTo(map);
     var popup3 = L.popup();
    function onMapClick3(e) {
    .setContent('Surf Brewery')

    map.on('click', onMapClick3);

     // Made West Brewery
    L.marker([ 34.255959, -119.237779], {icon: beer}).addTo(map);
     var popup4 = L.popup();
    function onMapClick4(e) {
    .setContent('Made West Brewery')

    map.on('click', onMapClick4);
  • 1
    Please edit your post to share the code you currently have. – Adrian Larson Mar 29 '17 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.