Skip to content

Commit

Permalink
do not hide icons if text is an empty string
Browse files Browse the repository at this point in the history
Empty text strings do not have any collision boxes so the collision
index check was never done and the text was not counted as "placed".
This fixes that by making "placed" the default when the feature has
text.

fix #6160
  • Loading branch information
ansis committed Feb 14, 2018
1 parent c422832 commit f3049d5
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
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
]
}
}
]
}

0 comments on commit f3049d5

Please sign in to comment.