Mapbox-gl-js: icon-text-fit should work with text-variable-anchor

Created on 1 Aug 2019  路  8Comments  路  Source: mapbox/mapbox-gl-js

Expected Behavior

When using these properties on a layer:

{
  'text-variable-anchor': ['left', 'top', 'right', 'bottom'],
  'text-justify': 'auto',
  'icon-text-fit': 'width'
}

I would expect both the icon that's been fitted under the label and the label to be variably placed.

Actual Behavior

Here's a label using a icon-text-fit background

| Without text-variable-anchor | With text-variable-anchor |
| --- | --- |
| Screen Shot 2019-08-01 at 9 08 34 AM | Screen Shot 2019-08-01 at 9 17 17 AM |


mapbox-gl-js version: v1.1.0
browser: Chrome Version 75.0.3770.142 (Official Build) (64-bit)

Link to Demonstration

https://jsfiddle.net/tristen/830prsyz/

bug

All 8 comments

cc @alexshalamov

@asheemmamoowala yes, it is a bug, we need to offset an icon together with a text. Also, would be nice to document that in a spec as well.

@alexshalamov, would be nice to document in the spec now that this property doesn't work with icon-text-fit, or to document that it _does_ after we close this issue?

@chloekraw please disregard my comment, after checking the spec, I think it should be clear how icon-text-fit and variable anchors work together, e.g., icon would be shifted together with the text.

@ansis could you please take a look at gl-native fix in https://github.com/mapbox/mapbox-gl-native/pull/14932/commits/19a49a5abbf53d40846af114ada0a9b1d25f3da0

Also, I had to fix it for combination of text-writing-mode with icon-text-fit.

@alexshalamov thanks for the investigation and proposed fix. per chat, I'm tracking that your next steps here are to split those commits out into a separate PR on GL-Native and to open a PR with render tests on GL-JS.

@chloekraw GL-Native PR #15367 render tests https://github.com/mapbox/mapbox-gl-js/pull/8625

Fixed in v1.4.0-beta.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bgentry picture bgentry  路  3Comments

stevage picture stevage  路  3Comments

BernhardRode picture BernhardRode  路  3Comments

foundryspatial-duncan picture foundryspatial-duncan  路  3Comments

rigoneri picture rigoneri  路  3Comments