dclipca
dclipca

Reputation: 1937

Scale marker size relative to the zoom level in Mapbox GL JS

I want to decrease the size of the markers when the zoom level of the map is increased. How can I achieve this?

Upvotes: 12

Views: 11723

Answers (1)

Steve Bennett
Steve Bennett

Reputation: 126687

You can use the interpolate expression with the zoom expression, along these lines:

"icon-size": ['interpolate', ['linear'], ['zoom'], 10, 1, 15, 0.5]

Documentation here: https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/#ramps-scales-curves

Upvotes: 21

Related Questions