I'm currently experimenting with adding a button inside a pointer that will log a message to the console. This is simply a test to see if I can execute a method on the marker, but so far I haven't been able to display any text.
const marker = L.marker([latitude, longitude]).addTo(map);
const button = '<br/><button type="button">Click button</button>'
const clickbutton = document.querySelector("#click");
button1.addEventListener("click", function(event) {
console.log('This button works!');
});
marker.bindPopup(button);
Upon loading the page, I encounter the following error:
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'addEventListener')
The error seems to be triggered by this line of code:
button1.addEventListener("click", function(event) {
I'm puzzled as to why it's returning null. Any assistance would be greatly appreciated!