美文网首页
mapboxgl实时修改图标透明度

mapboxgl实时修改图标透明度

作者: SarahLee1122 | 来源:发表于2021-11-04 11:50 被阅读0次

1.加载图层时,图标透明度设置为1.0

paint: {
            'icon-opacity':1.0,
            'text-color': 'rgba(255, 255, 255, 0.97)'
          }

2.闪烁某个要素图标

var time1 = setTimeout(function(){
        that.map.setPaintProperty('layerid', 'icon-opacity',
        ['case', ['match', ['get', 'id'], id, true, false], 0.5, 1]);
      },500)
      var time2 = setTimeout(function(){
        that.map.setPaintProperty('layerid', 'icon-opacity',1);
      },1000)
      var time3 = setTimeout(function(){
        that.map.setPaintProperty('layerid', 'icon-opacity',
        ['case', ['match', ['get', 'id'], id, true, false], 0.5, 1]);
      },1500)
      var time4 = setTimeout(function(){
        that.map.setPaintProperty('layerid', 'icon-opacity',1);
      },2000)

3.清除定时器

clearTimeout(this.time1)

效果图


闪烁.gif

相关文章

网友评论

      本文标题:mapboxgl实时修改图标透明度

      本文链接:https://www.haomeiwen.com/subject/gczhzltx.html