解决高德地图api叠加Imagelayer播放雷达图闪烁

12 篇文章 0 订阅
8 篇文章 0 订阅

项目是vue写的,引用高德JS

最开始,是先删除原来的图层,再叠加图层, 中间会出现一下闪烁的感觉,很恶心。

然后各种百度,看其他人的文章,也没什么收获。高德文档,翻了几圈了,注释的代码都一大堆,各种函数测试了一圈。

后来发现Imagelayer的一个事件,关键就在于这玩意,解决了大问题,播放看着就流畅了。

 

img_layers.on('complete', function() {

                    if (that.img_layers_list.length > 0) {
                        that.img_layers_list.forEach(a => {
                            that.map.removeLayer(a) //remove
                        })

                        that.img_layers_list = []
                    }
                    that.img_layers_list.push(img_layers)
                });

AddImage(op) {
				let that = this

				let zsj = op.min ? op.min : [70, 15] //全国范围的定位
				let yxj = op.max ? op.max : [140, 54]
				let zooms = [0, 20]

				//只能一直叠加,不能清理,不然地图会有闪动
				let img_layers = new AMap.ImageLayer({
					zIndex: 888, //设置大点,避免AMap.TileLayer.Satellite挡住
					url: op.imgurl,
					bounds: new AMap.Bounds(
						zsj, //左下角
						yxj //右上角
					),
					zooms: zooms,
				});
				//必须先加载完毕在清理,不然会有闪动的效果
				img_layers.on('complete', function() {

					if (that.img_layers_list.length > 0) {
						that.img_layers_list.forEach(a => {
							that.map.removeLayer(a) //remove
						})

						that.img_layers_list = []
					}
					that.img_layers_list.push(img_layers)
				});
				
				that.map.addLayer(img_layers)
			},

顺带记录下那个时间轴,也是恶心死了(0-100)的范围

let mllen = 100 / (this.LeiDa.length - 1)

计算步长,又会出现有小数点太多,

this.step = Math.floor(mllen * 100) / 100  换算吧

这里使用Math.floor,不进位,开始使用round(),直接给我溢出了100。。

js的小数运算真心恶心

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值