Skip to content

Commit

Permalink
Don't show an empty tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-arkenaar committed May 16, 2017
1 parent 0ed337e commit 4608488
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ L.Draw.Tooltip = L.Class.extend({
initialize: function (map) {
this._map = map;
this._popupPane = map._panes.popupPane;
this._visible = false;

this._container = map.options.drawControlTooltips ?
L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;
Expand Down Expand Up @@ -64,6 +65,14 @@ L.Draw.Tooltip = L.Class.extend({
'<span class="leaflet-draw-tooltip-subtext">' + labelText.subtext + '</span>' + '<br />' : '') +
'<span>' + labelText.text + '</span>';

if (!labelText.text && !labelText.subtext) {
this._visible = false;
this._container.style.visibility = 'hidden';
} else {
this._visible = true;
this._container.style.visibility = 'inherit';
}

return this;
},

Expand All @@ -74,7 +83,9 @@ L.Draw.Tooltip = L.Class.extend({
tooltipContainer = this._container;

if (this._container) {
tooltipContainer.style.visibility = 'inherit';
if (this._visible) {
tooltipContainer.style.visibility = 'inherit';
}
L.DomUtil.setPosition(tooltipContainer, pos);
}

Expand Down

0 comments on commit 4608488

Please sign in to comment.