Skip to content

Commit

Permalink
fix: don't set opacity before layer is added to map (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
turban authored Mar 11, 2021
1 parent 15b04e5 commit a05e04a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/layers/EarthEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class EarthEngine extends Layer {
const layerId = `${id}-polygon`
const mapgl = this.getMapGL()

if (mapgl.getLayer(layerId)) {
if (mapgl && mapgl.getLayer(layerId)) {
// Clickable polygon layer should always be transparent
mapgl.setPaintProperty(layerId, 'fill-opacity', 0)
}
Expand Down
6 changes: 5 additions & 1 deletion src/layers/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ class Layer extends Evented {
}

setOpacity(opacity) {
setLayersOpacity(this.getMapGL(), this.getId(), opacity)
const mapgl = this.getMapGL()

if (mapgl) {
setLayersOpacity(mapgl, this.getId(), opacity)
}
}

getBounds() {
Expand Down

0 comments on commit a05e04a

Please sign in to comment.