BeeNag
BeeNag

Reputation: 1844

Changing icon offset based on zoom level

I am trying to offset symbols of a symbol layer so that they don't interfere with a previous symbol layer (i.e. they don't overlap). I need to offset them as in both cases icon-allow-overlap needs to be set to true, as the symbols need to be viewable at all zoom levels. Ideally I'd like to do something like this:

"icon-offset": [
  ["zoom"],
  12, [-16, 0],
  22, [0, 0]
]

but that gives me an error:

array length 2 expected, length 5 found

Is there a way I can do what I want similar to what I was trying above? I know that icon-offset is not transitionable so that is why the above is failing.

Any help would be appreciated.

Thanks for your time.

Upvotes: 2

Views: 805

Answers (1)

BeeNag
BeeNag

Reputation: 1844

The answer was to use a function:

"icon-offset": {
  "stops": [
    [12, [-16, 0]],
    [22, [0, 0]]
  ]
}

More info on this can be found here

Upvotes: 2

Related Questions