vue, 高德地图,热力图

处理数据

// 初始化地图
        initMap(arr) {
            // eslint-disable-next-line no-undef
            // this.map = new AMap.Map("map", {
            const map = new AMap.Map("map", {
                mapStyle: "amap://styles/blue", // 设置地图的显示样式
                center: [112.225944, 32.093787],
                zoom: 15,
            });
            // 以下是热力图
            var heatmap;
            map.plugin(["AMap.HeatMap"], function() {
                // 初始化heatmap对象
                // eslint-disable-next-line no-undef
                heatmap = new AMap.HeatMap(map, {
                radius: 25, // 给定半径
                opacity: [0, 0.8],
                gradient: {
                    0.01: "#2D76D8",
                    0.2: "#47C9AE",
                    0.4: "#FF8B2E",
                    0.6: "#FD302D",
                    0.8: "#2E75DA",
                    1.0: "#C21D22",
                },
                });
                // 设置数据集
                heatmap.setDataSet({
                data: arr,
                // data: list,
                max: 50,
                });
            });
            console.log(heatmap);
        },
 const mapList = []
            res4.length > 0 && res4.map(item => {
                const mapNum = item.parkIndex.replace('%','')
                const obj = {
                    lng: item.lng,
                    lat: item.lat,
                    count: mapNum * 1
                }
                mapList.push(obj)
            })
            this.initMap(mapList)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值