I'm using in a mapbox gl layer in the layout-block the field text-offset.
layout: { // Working
'text-field': '{point_count_abbreviated}',
'text-size': ['step', ['get', 'point_count'], 18, 10, 14, 100, 12],
'text-offset': [-0.84, 0.23],
}
This is working as expected, but now I want to change the the offset based on a properties. This is working quite well for the 'text-size', but for the text-offset I can't find the right syntax. I've tried the following:
layout: { // NOT working
'text-field': '{point_count_abbreviated}',
'text-size': ['step', ['get', 'point_count'], 18, 10, 14, 100, 12],
'text-offset': [
// [-0.84, 0.23],
['step', ['get', 'point_count'], -0.84, 10, -0.94, 100, -0.99],
['step', ['get', 'point_count'], 0.23, 10, 0.25, 100, 0.28],
],
},
Maybe mapbox-gl isn't supporting a step ramp at the text-offset at the moment?
Error Message:
Error: layers.cluster-offline.layout.text-offset[0]: number expected, array found
layout: { // NOT working
'text-field': '{point_count_abbreviated}',
'text-size': ['step', ['get', 'point_count'], 18, 10, 14, 100, 12],
'text-offset': [
// [-0.84, 0.23],
['literal',
['step', ['get', 'point_count'], -0.84, 10, -0.94, 100, -0.99],
['step', ['get', 'point_count'], 0.23, 10, 0.25, 100, 0.28]
],
],
},
Error Message:
Error: layers.cluster-offline.layout.text-offset: array length 2 expected, length 1 found
layout: { // NOT working
'text-field': '{point_count_abbreviated}',
'text-size': ['step', ['get', 'point_count'], 18, 10, 14, 100, 12],
'text-offset': [
['literal', ['step', ['get', 'point_count'], -0.84, 10, -0.94, 100, -0.99]],
['literal', ['step', ['get', 'point_count'], 0.23, 10, 0.25, 100, 0.28]],
],
},
Error Message:
Error: layers.cluster-offline.layout.text-offset[0]: number expected, array found
text-fieldthough. - Steve Bennett