Skip to content

Commit

Permalink
Fix rendering for icon-text-fit + data-driven text-size
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Nov 13, 2017
1 parent 7386da6 commit a4bc58e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/symbol/quads.js
Expand Up @@ -71,7 +71,7 @@ function getIconQuads(anchor: Anchor,
if (layout['icon-text-fit'] !== 'none' && shapedText) {
const iconWidth = (right - left),
iconHeight = (bottom - top),
size = layout['text-size'] / 24,
size = layer.getLayoutValue('text-size', globalProperties, feature) / 24,
textLeft = shapedText.left * size,
textRight = shapedText.right * size,
textTop = shapedText.top * size,
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,74 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 64
}
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "A",
"size": 12
},
"geometry": {
"type": "Point",
"coordinates": [
-10,
0
]
}
},
{
"type": "Feature",
"properties": {
"name": "B",
"size": 24
},
"geometry": {
"type": "Point",
"coordinates": [
10,
0
]
}
}
]
}
}
},
"sprite": "local://sprites/icon-text-fit",
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"layout": {
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
],
"text-field": [
"get",
"name"
],
"text-size": [
"get",
"size"
],
"icon-image": "label",
"icon-text-fit": "both",
"icon-ignore-placement": true,
"icon-allow-overlap": true
}
}
]
}

0 comments on commit a4bc58e

Please sign in to comment.