一、创建随机数JS代码
function rondomNum(){ return parseFloat(Math.random()*1000).toFixed(0); }
二、地图县市名称及值
var cityData = [ {name: '阿克苏市', value: rondomNum()}, {name: '温宿县', value: rondomNum()}, {name: '库车县', value: rondomNum()}, {name: '沙雅县', value: rondomNum()}, {name: '新和县', value: rondomNum()}, {name: '拜城县', value: rondomNum()}, {name: '乌什县', value: rondomNum()}, {name: '阿瓦提县', value: rondomNum()}, {name: '柯坪县', value: rondomNum()}, {name: '安康市', value: rondomNum()} ];
三、比较数组参数,选取最大值;
var cityMax = cityData[0].value; for (var i = 0; i < cityData.length - 1; i++) { cityMax = cityMax < cityData[i + 1].value ? cityData[i + 1].value : cityMax }
visualMap中,max=cityMax即可.
Done!