agssl
agssl

Reputation: 153

How to add opacity transition for mapbox symbol layer

I have a mapbox layer (created in studio) with different icons based on data conditions. Now I'm adding a toolbar to show and hide various icons based on the filter. This works great, but I want to adjust the transition to make it a bit smoother.

I've read some posts about icon-opacity-transition, but it didn't work for me.

  map.setPaintProperty('layer-name', 'icon-opacity-transition', { "duration": 300 } );

results in cannot read property 'value' of undefined

Is it possible to change the icon-opacity transition or is it at least possible to show and hide a layer with some custom transition values?

Upvotes: 1

Views: 1568

Answers (1)

cantuket
cantuket

Reputation: 1592

Not sure if this will help you still, but it was very important for our project. Its a 'global map property' called 'fadeDuration'...

new mapboxgl.Map({
  fadeDuration: 0,
  ...
})

I'm not sure about accessing by layer though...

https://github.com/mapbox/mapbox-gl-js/issues/6519#issuecomment-390001993

Upvotes: 2

Related Questions