Allow to create and open a tooltip without source (fix #4827) (#4836)

This commit is contained in:
Yohan Boniface 2016-08-25 15:29:20 +02:00 committed by Vladimir Agafonkin
parent db823b6967
commit 7927708b40
2 changed files with 10 additions and 1 deletions

View File

@ -278,5 +278,14 @@ describe('Tooltip', function () {
L.Browser.touch = oldTouch;
});
it("opens with map.openTooltip", function (done) {
map.on('tooltipopen', function (e) {
expect(map.hasLayer(e.tooltip)).to.be(true);
done();
});
map.openTooltip('Tooltip', center);
});
});

View File

@ -174,7 +174,7 @@ L.Tooltip = L.DivOverlay.extend({
_getAnchor: function () {
// Where should we anchor the tooltip on the source layer?
return L.point(this._source._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]);
return L.point(this._source && this._source._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]);
}
});