1

I'm trying to move a text field using the text-translate and interpolate features.

But if I use the get expression inside interpolate to gather a property from the source, it stops working.

Any idea as to why this is happening?

Sample:

'text-translate': [
  'interpolate',
  ['exponential', 2],
  ['zoom'],
  0,
  [
    'literal',
    [0, 0]
  ],
  20,
  [
    'literal',
    [
      0,
      ['get', NAME_OF_PROPERTY],
    ],
  ]
],

If I don't use get there, it works perfectly fine, so there might be something wrong with that expression.

1 Answers1

0

You're putting your get inside a literal expression, so it's being treated as a literal.

I'm not certain, but perhaps the second part of your expression should be:

20,
[0, ['get', NAME_OF_PROPERTY]]

or perhaps:

20,
[['to-number', 0], ['get', NAME_OF_PROPERTY]]
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219