【问题标题】:Set tooltip on custom leafletjs control在自定义leafletjs控件上设置工具提示
【发布时间】:2015-08-05 15:19:21
【问题描述】:

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

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
  • 该 URL 似乎被破坏了,仅仅六年后。内管到底是什么来的??!!

标签: javascript tooltip leaflet


【解决方案1】:

为了回答我自己的问题,我使用了错误的方法来添加标题选项。通过首先创建容器,然后在我能够填充标题字段并在悬停时设置工具提示后设置标题。

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 一起使用 :-(
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-14
  • 1970-01-01
相关资源
最近更新 更多