I have made several custom buttons in Leafletjs - now I would like to add a hover-over tooltip to explain what the button does. I've tried putting a "title:" and "tooltip:" in the options but still do not see the text when I hover over the control.
var load = L.Control.extend({
options: {
position: 'topright'
},
onAdd: function(map) {
var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control leaflet-control-load-points');
//container.style.backgroundColor = 'white';
container.style.width = '25px';
container.style.height = '25px';
container.onclick = function() {
clear_markers(markers);
load_markers(markers);
}
return container;
},
});
I have made several custom buttons in Leafletjs - now I would like to add a hover-over tooltip to explain what the button does. I've tried putting a "title:" and "tooltip:" in the options but still do not see the text when I hover over the control.
var load = L.Control.extend({
options: {
position: 'topright'
},
onAdd: function(map) {
var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control leaflet-control-load-points');
//container.style.backgroundColor = 'white';
container.style.width = '25px';
container.style.height = '25px';
container.onclick = function() {
clear_markers(markers);
load_markers(markers);
}
return container;
},
});
Share
Improve this question
edited Feb 3, 2016 at 0:25
raphael
2,8435 gold badges29 silver badges57 bronze badges
asked May 23, 2015 at 18:47
terra_maticsterra_matics
2393 silver badges8 bronze badges
2
- You could try hint.css – Jonatas Walker Commented May 23, 2015 at 18:56
- 1 The URL seems to be broken, a mere six years later. Whart on earth are the inter-tubes ing to??!! – Mawg Commented Jan 18, 2021 at 11:04
1 Answer
Reset to default 7To answer my own question I was using the wrong approach to add the title option. By creating the container first and then setting the title after I was able to populate the title field and have a tooltip work on hover over.
var load = L.Control.extend({
options: {position: 'topright'},
onAdd: function(map) {
var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control leaflet-control-load');
container.title = "Enter Tooltip Here"
}
});