I have a very simple leaflet map which has a set of easy buttons whose function is to add and remove layers from the map.
I'd like to set tooltip or mouseover or hover so when the user moves the mouse over the buttons they get a message. Simple.
Here's an example of the code for the layers, then for the buttons:
//layer coding
var buildings = L.geoJson(buildings,{
style: function(feature, layer){
return {
color: "purple",
fillOpacity: 9,
weight: 2
};
},
}).addTo(map);
//button coding
L.easyButton('<img class="icon" src="icons/house.png">',
function(btn, map){
if (map.hasLayer(buildings)){
map.removeLayer(buildings);
} else {
map.addLayer(buildings);
};
}).addTo( map );
Best Answer
Modifying the last line works for me.