Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popup/Tooltip content function: allow return undefined #6599

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/layer/DivOverlay.js
Expand Up @@ -175,6 +175,10 @@ export var DivOverlay = Layer.extend({
this.fire('contentupdate');
},

_hasContentFor: function (layer) {
return typeof this._content !== 'function' || this._content(layer || this);
},

_updatePosition: function () {
if (!this._map) { return; }

Expand Down
2 changes: 1 addition & 1 deletion src/layer/Popup.js
Expand Up @@ -434,7 +434,7 @@ Layer.include({
latlng = layer.getCenter ? layer.getCenter() : layer.getLatLng();
}

if (this._popup && this._map) {
if (this._popup && this._map && this._popup._hasContentFor(layer)) {
// set popup source to this layer
this._popup._source = layer;

Expand Down
2 changes: 1 addition & 1 deletion src/layer/Tooltip.js
Expand Up @@ -328,7 +328,7 @@ Layer.include({
latlng = layer.getCenter ? layer.getCenter() : layer.getLatLng();
}

if (this._tooltip && this._map) {
if (this._tooltip && this._map && this._tooltip._hasContentFor(layer)) {

// set tooltip source to this layer
this._tooltip._source = layer;
Expand Down