react+百度地图 覆盖物出现动态光圈效果

2 篇文章 0 订阅

首先在less文件中创建动画,将动画绑定到类上:

@keyframes scale{
  0% {
        transform: scale(0);
        // background-color: rgba(255, 255, 255, 0);
  }
  50% {
      transform: scale(0.5);
      // background-color: RGBA(29, 221, 146, 0.3);
  }
  70% {
      // background-color: RGBA(29, 221, 146, 0.3);
  }
  100% {
      transform: scale(1);
      // background-color: RGBA(40, 223, 152, 0.1);
      // opacity: 0.0;
  }
}
.classScale{
    animation: scale 2s linear infinite normal;
}

在创建覆盖物的方法内根据传入数据type不同决定是否出现光圈效果:

const option = {
   position: point,
   offset: new BMap.Size(-50, -50),
};

const valueLabel = new BMap.Label(`<div class=${item.type === 'car' ? style.classScale : ''} style='width:100px;height:100px;border:1px solid RGBA(40, 223, 152, 0.1);background-color:RGBA(40, 223, 152, 0.1);border-radius:50%;'></div>`, option);
valueLabel.setStyle({
   border: 'none',
   backgroundColor: 'RGBA(0,0,0,0)',
});
map.addOverlay(valueLabel);

头部要将less文件以下面的方式引入:

import style from '../../styles/views/Sensing.less';

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值