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

do not hide icons if text is an empty string #6164

Merged
merged 2 commits into from
Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ export type CollisionArrays = {
textCircles?: Array<number>;
};

export type SymbolFeature = {|
text: string | void,
icon: string | void,
index: number,
sourceLayerIndex: number,
geometry: Array<Array<Point>>,
properties: Object,
type: 'Point' | 'LineString' | 'Polygon',
id?: any
|};

export type SymbolInstance = {
key: string,
textBoxStartIndex: number,
Expand All @@ -76,7 +87,7 @@ export type SymbolInstance = {
anchor: Anchor,
line: Array<Point>,
featureIndex: number,
feature: ExpressionFeature,
feature: SymbolFeature,
textCollisionFeature?: {boxStartIndex: number, boxEndIndex: number},
iconCollisionFeature?: {boxStartIndex: number, boxEndIndex: number},
placedTextSymbolIndices: Array<number>;
Expand All @@ -92,17 +103,6 @@ export type SymbolInstance = {
hidden?: boolean;
};

export type SymbolFeature = {|
text: string | void,
icon: string | void,
index: number,
sourceLayerIndex: number,
geometry: Array<Array<Point>>,
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
Expand Down
4 changes: 2 additions & 2 deletions src/symbol/placement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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
]
}
}
]
}