diff --git a/src/data/bucket/symbol_bucket.js b/src/data/bucket/symbol_bucket.js index cadf77f1d00..00c0ebe44d7 100644 --- a/src/data/bucket/symbol_bucket.js +++ b/src/data/bucket/symbol_bucket.js @@ -65,6 +65,17 @@ export type CollisionArrays = { textCircles?: Array; }; +export type SymbolFeature = {| + text: string | void, + icon: string | void, + index: number, + sourceLayerIndex: number, + geometry: Array>, + properties: Object, + type: 'Point' | 'LineString' | 'Polygon', + id?: any +|}; + export type SymbolInstance = { key: string, textBoxStartIndex: number, @@ -76,7 +87,7 @@ export type SymbolInstance = { anchor: Anchor, line: Array, featureIndex: number, - feature: ExpressionFeature, + feature: SymbolFeature, textCollisionFeature?: {boxStartIndex: number, boxEndIndex: number}, iconCollisionFeature?: {boxStartIndex: number, boxEndIndex: number}, placedTextSymbolIndices: Array; @@ -92,17 +103,6 @@ export type SymbolInstance = { hidden?: boolean; }; -export type SymbolFeature = {| - text: string | void, - icon: string | void, - index: number, - sourceLayerIndex: number, - geometry: Array>, - properties: Object, - type: 'Point' | 'LineString' | 'Polygon', - id?: any -|}; - // Opacity arrays are frequently updated but don't contain a lot of information, so we pack them // tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph // 7 bits are for the current opacity, and the lowest bit is the target opacity diff --git a/src/symbol/placement.js b/src/symbol/placement.js index eef09402770..7de69bbabb0 100644 --- a/src/symbol/placement.js +++ b/src/symbol/placement.js @@ -118,8 +118,8 @@ class Placement { for (const symbolInstance of bucket.symbolInstances) { if (!seenCrossTileIDs[symbolInstance.crossTileID]) { - let placeText = false; - let placeIcon = false; + let placeText = symbolInstance.feature.text !== undefined; + let placeIcon = symbolInstance.feature.icon !== undefined; let offscreen = true; let placedGlyphBoxes = null; diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#6160/expected.png b/test/integration/render-tests/regressions/mapbox-gl-js#6160/expected.png new file mode 100644 index 00000000000..be74a15a32f Binary files /dev/null and b/test/integration/render-tests/regressions/mapbox-gl-js#6160/expected.png differ diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#6160/style.json b/test/integration/render-tests/regressions/mapbox-gl-js#6160/style.json new file mode 100644 index 00000000000..693bec2bd7f --- /dev/null +++ b/test/integration/render-tests/regressions/mapbox-gl-js#6160/style.json @@ -0,0 +1,73 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64, + "description": "Checks that icons are not hidden when the text is an empty string" + } + }, + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + }, + "properties": { + "text": "OK" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 20, + 0 + ] + }, + "properties": { + "text": "" + } + } + ] + } + } + }, + "sprite": "local://sprites/sprite", + "layers": [ + { + "id": "symbol", + "type": "symbol", + "source": "geojson", + "layout": { + "symbol-placement": "point", + "text-allow-overlap": true, + "icon-allow-overlap": true, + "icon-image": "triangle-12", + "text-field": "{text}", + "text-font": [ + "Open Sans Semibold", + "Arial Unicode MS Bold" + ] + }, + "paint": { + "icon-opacity": 0.5, + "text-translate": [ + -10, + 0 + ] + } + } + ] +}