Is there any way to stop the job?



  • When pressed on the button, I have a window on my left of the map, and the possibility of placing the marker on the screen, after the window is closed, the possibility of placing the marker should disappear. I got him on the chequebox so he could only work when he was switched on, and then he turned off, but it didn't work. I'm just starting to work with that language, and I'm happy to have any help. Thank you.

    document.querySelector('.checkbox').addEventListener('click',() =>{
      if(document.querySelector('.checkbox').checked){
          var theMarker = {};
    
      map.on('click', function (e) {
        lat = e.latlng.lat;
        lon = e.latlng.lng;
    
        console.log("You clicked the map at LAT: " + lat + " and LONG: " + lon);
        //Clear existing marker,
    
        if (theMarker != undefined) {
          map.removeLayer(theMarker);
        }
        ;
    
        //Add a marker to show where you clicked.
        theMarker = L.marker([lat, lon]).addTo(map);
    
      });
    

    }else {
    }
    });



  • Is there any way to stop the job?


    Complete the function by the operator https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Statements/return

    Pay attention to: He's not just gonna stop the job, but he's gonna get the meaning back. That means that the challenge to the function will be what you've returned as a result.

    Cease the cycle work;



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2