diff --git a/src/source/tile.js b/src/source/tile.js index dcb8120bf2b..25164718dee 100644 --- a/src/source/tile.js +++ b/src/source/tile.js @@ -405,7 +405,7 @@ class Tile { bucket.update(sourceLayerStates, sourceLayer, this.imageAtlas && this.imageAtlas.patternPositions || {}); const layer = painter && painter.style && painter.style.getLayer(id); - if (layer && layer.paint) { + if (layer) { this.queryPadding = Math.max(this.queryPadding, layer.queryRadius(bucket)); } } diff --git a/src/style/style_layer.js b/src/style/style_layer.js index ce06dcb9ace..c2a7d6cb0cb 100644 --- a/src/style/style_layer.js +++ b/src/style/style_layer.js @@ -10,7 +10,7 @@ import { emitValidationErrors } from './validate_style'; import {Evented} from '../util/evented'; -import {Layout, Transitionable, Transitioning, Properties, PossiblyEvaluatedPropertyValue} from './properties'; +import {Layout, Transitionable, Transitioning, Properties, PossiblyEvaluated, PossiblyEvaluatedPropertyValue} from './properties'; import {supportsPropertyExpression} from '../style-spec/util/properties'; import type {FeatureState} from '../style-spec/expression'; @@ -100,6 +100,8 @@ class StyleLayer extends Evented { } this._transitioningPaint = this._transitionablePaint.untransitioned(); + //$FlowFixMe + this.paint = new PossiblyEvaluated(properties.paint); } } diff --git a/test/unit/style/style_layer.test.js b/test/unit/style/style_layer.test.js index 9152dc82f34..8d682f164ad 100644 --- a/test/unit/style/style_layer.test.js +++ b/test/unit/style/style_layer.test.js @@ -403,5 +403,12 @@ test('StyleLayer#serialize', (t) => { t.end(); }); + t.test('layer.paint is never undefined', (t) => { + const layer = createStyleLayer({type: 'fill'}); + // paint is never undefined + t.ok(layer.paint); + t.end(); + }); + t.end(); });