0
votes

In Mapbox how i can sum a value to an expression?

"text-field": ["get", "data"],

I have try a lot of solution like ["get", "data"] + 2 or ["get", "data" + 2] but they don't works!

1

1 Answers

0
votes

There is a specific expression syntax for mathematical operations: https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-math

To work, your example should actually be written something like the following:

["+", ["get", "data"], 2]

(Addition syntax reference lives here.)


⚠️ Disclaimer: I currently work at Mapbox ⚠️