我借鉴JavaScript的示范程序里面热力图的源码写了一个页面,然后用Ajax向后台获取了很多个点的位置和人数,想要循环把每个位置的人数用热力图表示出来,但是我测试的时候发现只画了第一个点的人数热力图,我应该怎么改才能画出全部点的人数热力图?
$.ajax({
url:'http://192.168.8.249:8080/wifi/ap/list?'+'floor='+ff,
type:'get',
data:'',
dataType:'json',
cache:false,
async:false,
success:function(data){
console.log(data);
for(var i=0;i<data.length;i++){
var p = data[i];
var lat = p.latitude;
var lon = p.longitude;
var num = p.onlineNum;
createHeatPoints(num,lon,lat);
}
}
});
function createHeatPoints(Number,lon,lat) {
var heatPoints = [];
var num = 1;
var radius = Number;
var unit = 'px',
useGeoRadius = false;
if("degree" == unit) {
useGeoRadius = true;
}
heatMapLayer.radius = radius
for(var i = 0; i < num; i++) {
heatPoints[i] = new SuperMap.Feature.Vector(
new SuperMap.Geometry.Point(
lon,
lat
), {
"value":1,
"geoRadius": useGeoRadius ? radius : null
}
);
}
heatMapLayer.addFeatures(heatPoints);
}