处理数据
// 初始化地图
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)