1 回答
TA贡献1812条经验 获得超5个赞
showHeatMap();//页面加载时请求数据,渲染用户界面
var heatmap;
//map为高德地图实例,AMap.Heatmap为高德地图热力图插件
map.plugin(["AMap.Heatmap"], function () {
heatmap = new AMap.Heatmap(map, {
radius: 45, //给定半径
opacity: [0, 0.9],
gradient: {
0.2: $.cookie("little") != undefined ? $.cookie("little") : '#4AA329',
0.5: $.cookie("a_little") != undefined ? $.cookie("a_little") : '#1F7B67',
0.7: $.cookie("many") != undefined ? $.cookie("many") : '#A63F00',
0.95: $.cookie("plenty") != undefined ? $.cookie("plenty") : '#9D0019'
}
});
});
setInterval(showHeatMap,5000);//每隔5秒请求服务器获取最新数据
function showHeatMap(){
$.get({
url:"/getdata",
dataType:"json",
success:function(data){
console.log(data);
heatmap.setDataSet({
data: data,
min: 10
});
},
error:function(xmlHttpRequest,err,catchError){
console.log(xmlHttpRequest);
console.log(err);
console.log(catchError);
}
});
}
添加回答
举报