Skip to content

Commit

Permalink
fix: only set feature hover state if layer is still on map
Browse files Browse the repository at this point in the history
  • Loading branch information
turban committed Mar 9, 2021
1 parent fa391a4 commit bb91920
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/layers/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,20 @@ class Layer extends Evented {

// Highlight a layer feature
highlight(id) {
const feature = id ? this.getFeature(id) : null

this.getMap().setHoverState(
feature
? {
id: feature.id,
source: this.getId(),
}
: null
)
const map = this.getMap()

if (map) {
const feature = id ? this.getFeature(id) : null

map.setHoverState(
feature
? {
id: feature.id,
source: this.getId(),
}
: null
)
}
}

// Override if needed in subclass
Expand Down

0 comments on commit bb91920

Please sign in to comment.