2015-05-23 60 views
2

我在Leafletjs中製作了幾個自定義按鈕 - 現在我想添加一個懸停工具提示來解釋按鈕的功能。我嘗試在選項中放置「標題:」和「工具提示:」,但當我將鼠標懸停在控件上時仍然看不到文字。在自定義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; 
    }, 
}); 
+0

你可以試試[hint.css](http://kushagragour.in/lab/hint/) –

回答

3

要回答我自己的問題,我使用了錯誤的方法來添加標題選項。首先創建容器,然後設置標題,然後填充標題字段並將鼠標懸停在工具提示上。

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" 

);