在LeafletJS自定义控件中设置工具提示

5

我在Leafletjs中创建了几个自定义按钮-现在我想添加一个悬停工具提示来解释这个按钮的作用。我已经尝试在选项中添加"title:"和"tooltip:",但是当我将鼠标悬停在控件上时,仍然看不到文本。

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;
    },
});

你可以尝试使用hint.css - Jonatas Walker
1
这个URL似乎在六年后已经失效了。互联网到底要变成什么样子啊?! - Mawg says reinstate Monica
1个回答

7
为了回答我的问题,我使用了错误的方法来添加标题选项。首先创建容器,然后设置标题,这样我就能填充标题字段并在悬停时使用工具提示功能。
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"
    }
});

我无法让它在标题中与HTML一起工作 :-( - Mawg says reinstate Monica

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接