I have a function which creates a marker and binds a popup to it. I want the popup to open and close with a single mouse click. What happens is that the popup doesn't open on the first click. Second click and all the subsequent clicks do the job. No errors in the browser console. What can be the problem?
Here's the code:
function addPlace() {
var myIcon = L.icon({
iconUrl: 'images/store.png',
iconSize: [45, 47],
iconAnchor: [22, 94],
popupAnchor: [-3, -76],
});
var popup1 = L.popup()
.setLatLng([32.07753, 34.76988])
.setContent("Best shop<br>Food, drinks and more")
var shop = L.marker([32.07714, 34.76988], {icon: myIcon})
.on('click', function() { shop.bindPopup(popup1); })
.addTo(mymap);
};