Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 565
dclipca Avatar asked Apr 04 '20 18:04

dclipca


People also ask

What are the zoom levels?

A zoom level or scale is a number that defines how large or small the contents of a map appear in a map view . Scale is a ratio between measurements on a map view and measurements in the real-world.

What is BBOX in Mapbox?

A bounding box is a mechanism for describing a particular area of a map.


1 Answers

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

like image 61
Steve Bennett Avatar answered Oct 12 '22 12:10

Steve Bennett