Make sure label has been opened before trying to interact with its container

This commit is contained in:
Yohan Boniface 2016-07-05 09:07:36 +02:00
parent c56d48b3e1
commit 0726f12bbf

View File

@ -101,7 +101,9 @@ L.Layer.include({
// open the label on the map // open the label on the map
this._map.openLabel(this._label, latlng); this._map.openLabel(this._label, latlng);
if (this._label.options.interactive) { // Label container may not be defined if not permanent and never
// opened.
if (this._label.options.interactive && this._label._container) {
L.DomUtil.addClass(this._label._container, 'leaflet-clickable'); L.DomUtil.addClass(this._label._container, 'leaflet-clickable');
this.addInteractiveTarget(this._label._container); this.addInteractiveTarget(this._label._container);
} }