138 lines
60 KiB
JavaScript
138 lines
60 KiB
JavaScript
|
var cityGeo = {};
|
||
|
for (var p in chinaCityGeo) {
|
||
|
var province = chinaCityGeo[p];
|
||
|
for (var city in province) {
|
||
|
cityGeo[city] = province[city];
|
||
|
}
|
||
|
}
|
||
|
// 补充几个地理信息
|
||
|
cityGeo['盘锦'] = {y:41.119997, x:122.070714};
|
||
|
cityGeo['舟山'] = {y:29.985295, x:122.207216};
|
||
|
cityGeo['葫芦岛'] = {y:40.711052, x:120.836932};
|
||
|
cityGeo['胶州'] = {y:36.264622, x:120.03336};
|
||
|
cityGeo['台州'] = {y:28.656386, x:121.420757};
|
||
|
cityGeo['鄂尔多斯'] = {y:39.608266, x:109.781327};
|
||
|
cityGeo['三亚'] = {y:18.252847, x:109.511909};
|
||
|
cityGeo['莱州'] = {y:37.177017, x:119.942327};
|
||
|
cityGeo['瓦房店'] = {y:39.627114, x:121.979603};
|
||
|
cityGeo['嘉峪关'] = {y:39.77313, x:98.289152};
|
||
|
cityGeo['湛江'] = {y:21.270708, x:110.359377};
|
||
|
cityGeo['张家港'] = {y:31.875428, x:120.555821};
|
||
|
cityGeo['汕尾'] = {y:22.786211, x:115.375279};
|
||
|
cityGeo['攀枝花'] = {y:26.582347, x:101.718637};
|
||
|
cityGeo['南充'] = {y:30.837793, x:106.110698};
|
||
|
cityGeo['自贡'] = {y:29.33903, x:104.778442};
|
||
|
cityGeo['金昌'] = {y:38.520089, x:102.188043};
|
||
|
cityGeo['张家界'] = {y:29.117096, x:110.479191};
|
||
|
cityGeo['荆州'] = {y:30.335165, x:112.239741};
|
||
|
cityGeo['菏泽'] = {y:35.23375, x:115.480656};
|
||
|
|
||
|
var data = {
|
||
|
oriData : [],
|
||
|
cityToData : {},
|
||
|
//cityArray : [],
|
||
|
aqi : [], aqiMin:0, aqiMax:500,
|
||
|
pm25 : [], pm25Min:0, pm25Max:800,
|
||
|
pm10 : [], pm10Min:0, pm10Max:800,
|
||
|
co : [], coMin:0, coMax:15,
|
||
|
no2 : [], no2Min:0, no2Max:300,
|
||
|
o3 : [], o3Min:0, o3Max:300,
|
||
|
so2 : [], so2Min:0, so2Max:500,
|
||
|
geoCoord : {}
|
||
|
};
|
||
|
data.format = function (oriData) {
|
||
|
data.oriData = oriData;
|
||
|
var city;
|
||
|
var cityToData = {};
|
||
|
//var cityArray = [];
|
||
|
var geoCoord = {};
|
||
|
function pushData(key, city, value) {
|
||
|
data[key].push({name:city, value:value});
|
||
|
// data[key+'Min'] = Math.min(data[key+'Min'], value);
|
||
|
// data[key+'Max'] = Math.max(data[key+'Max'], value);
|
||
|
}
|
||
|
var singleData;
|
||
|
for (var i = 0, l = oriData.length; i < l; i++) {
|
||
|
singleData = oriData[i]
|
||
|
city = singleData.area;
|
||
|
//cityArray.push(city);
|
||
|
cityToData[city] = singleData;
|
||
|
pushData('aqi', city, singleData.aqi);
|
||
|
pushData('pm25', city, singleData.pm2_5);
|
||
|
pushData('pm10', city, singleData.pm10);
|
||
|
pushData('co', city, singleData.co);
|
||
|
pushData('no2', city, singleData.no2);
|
||
|
pushData('o3', city, singleData.o3);
|
||
|
pushData('so2', city, singleData.so2);
|
||
|
geoCoord[city] = cityGeo[city];
|
||
|
}
|
||
|
|
||
|
function sortData(a, b) {
|
||
|
return a.value - b.value
|
||
|
}
|
||
|
data['aqi'].sort(sortData);
|
||
|
data['pm25'].sort(sortData);
|
||
|
data['pm10'].sort(sortData);
|
||
|
data['co'].sort(sortData);
|
||
|
data['no2'].sort(sortData);
|
||
|
data['o3'].sort(sortData);
|
||
|
data['so2'].sort(sortData);
|
||
|
|
||
|
data.oriData = oriData;
|
||
|
data.cityToData = cityToData;
|
||
|
//data.cityArray = cityArray;
|
||
|
data.geoCoord = geoCoord;
|
||
|
}
|
||
|
|
||
|
// 重点城市的人口和GDP
|
||
|
var PG = {
|
||
|
'北京':{pop:1297.46, gdp:17879.4},
|
||
|
'天津':{pop:993.2, gdp:12893.88},
|
||
|
'石家庄':{pop:1005.33, gdp:4500.2},
|
||
|
'太原':{pop:365.84, gdp:2311.4},
|
||
|
'呼和浩特':{pop:230.32, gdp:2475.6},
|
||
|
'沈阳':{pop:724.79, gdp:6602.6},
|
||
|
'大连':{pop:590.31, gdp:7002.8},
|
||
|
'长春':{pop:756.9, gdp:4456.6},
|
||
|
'哈尔滨':{pop:993.53, gdp:4550.2},
|
||
|
'上海':{pop:1426.93, gdp:20181.72},
|
||
|
'南京':{pop:638.48, gdp:7201.6},
|
||
|
'杭州':{pop:700.52, gdp:7802},
|
||
|
'宁波':{pop:577.71, gdp:6582.2},
|
||
|
'合肥':{pop:710.53, gdp:4164.3},
|
||
|
'福州':{pop:655.27, gdp:4218.3},
|
||
|
'厦门':{pop:190.92, gdp:2817.1},
|
||
|
'南昌':{pop:507.87, gdp:3000.5},
|
||
|
'济南':{pop:609.21, gdp:4803.7},
|
||
|
'青岛':{pop:769.56, gdp:7302.1},
|
||
|
'郑州':{pop:1072.5, gdp:5549.8},
|
||
|
'武汉':{pop:821.71, gdp:8003.8},
|
||
|
'长沙':{pop:660.62, gdp:6399.9},
|
||
|
'广州':{pop:822.3, gdp:13551.2},
|
||
|
'深圳':{pop:287.62, gdp:12950.1},
|
||
|
'南宁':{pop:713.5, gdp:2503.2},
|
||
|
'海口':{pop:161.59, gdp:818.8},
|
||
|
'重庆':{pop:3343.44, gdp:11409.6},
|
||
|
'成都':{pop:1173.3, gdp:8138.9},
|
||
|
'贵阳':{pop:374.53, gdp:1700.3},
|
||
|
'昆明':{pop:543.48, gdp:3011.1},
|
||
|
'拉萨':{pop:50, gdp:260.1},
|
||
|
'西安':{pop:795.98, gdp:4366.1},
|
||
|
'兰州':{pop:321.52, gdp:1563.8},
|
||
|
'西宁':{pop:198.46, gdp:851.1},
|
||
|
'银川':{pop:167.22, gdp:1150.9},
|
||
|
'乌鲁木齐':{pop:257.8, gdp:2004.1}
|
||
|
};
|
||
|
|
||
|
//颜色映射
|
||
|
var eColorMap = {
|
||
|
'aqi' : '#87cefa',
|
||
|
'pm25' : '#ff7f50',
|
||
|
'pm10' : '#da70d6',
|
||
|
'co' : '#32cd32',
|
||
|
'no2' : '#6495ed',
|
||
|
'o3' : '#ff69b4',
|
||
|
'so2' : '#87cefa'
|
||
|
};
|
||
|
|
||
|
var testData = [{"aqi":23,"area":"北京","co":0.4,"co_24h":0.464,"no2":11,"no2_24h":25,"o3":58,"o3_24h":62,"o3_8h":44,"o3_8h_24h":57,"pm10":23,"pm10_24h":20,"pm2_5":14,"pm2_5_24h":17,"quality":"优","level":"一级","so2":11,"so2_24h":14,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":26,"area":"莱西","co":0.135,"co_24h":0.652,"no2":10,"no2_24h":30,"o3":66,"o3_24h":65,"o3_8h":52,"o3_8h_24h":59,"pm10":25,"pm10_24h":87,"pm2_5":13,"pm2_5_24h":61,"quality":"优","level":"一级","so2":16,"so2_24h":46,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":26,"area":"荣成","co":0.084,"co_24h":0.436,"no2":9,"no2_24h":15,"o3":25,"o3_24h":40,"o3_8h":27,"o3_8h_24h":36,"pm10":25,"pm10_24h":65,"pm2_5":8,"pm2_5_24h":46,"quality":"优","level":"一级","so2":14,"so2_24h":28,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":26,"area":"盘锦","co":1.031,"co_24h":0.862,"no2":5,"no2_24h":20,"o3":73,"o3_24h":67,"o3_8h":50,"o3_8h_24h":56,"pm10":25,"pm10_24h":25,"pm2_5":12,"pm2_5_24h":32,"quality":"优","level":"一级","so2":24,"so2_24h":38,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":26,"area":"丹东","co":0.566,"co_24h":1.083,"no2":12,"no2_24h":30,"o3":60,"o3_24h":60,"o3_8h":47,"o3_8h_24h":47,"pm10":25,"pm10_24h":69,"pm2_5":11,"pm2_5_24h":47,"quality":"优","level":"一级","so2":19,"so2_24h":64,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":27,"area":"营口","co":0.379,"co_24h":0.494,"no2":8,"no2_24h":16,"o3":67,"o3_24h":67,"o3_8h":53,"o3_8h_24h":58,"pm10":20,"pm10_24h":23,"pm2_5":8,"pm2_5_24h":10,"quality":"优","level":"一级","so2":27,"so2_24h":45,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":28,"area":"本溪","co":2.274,"co_24h":2.538,"no2":25,"no2_24h":33,"o3":39,"o3_24h":49,"o3_8h":35,"o3_8h_24h":37,"pm10":27,"pm10_24h":50,"pm2_5":12,"pm2_5_24h":25,"quality":"优","level":"一级","so2":52,"so2_24h":57,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":29,"area":"文登","co":0.454,"co_24h":0.733,"no2":16,"no2_24h":12,"o3":57,"o3_24h":78,"o3_8h":49,"o3_8h_24h":78,"pm10":28,"pm10_24h":51,"pm2_5":10,"pm2_5_24h":67,"quality":"优","level":"一级","so2":12,"so2_24h":28,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":29,"area":"平度","co":0,"co_24h":0.673,"no2":15,"no2_24h":34,"o3":63,"o3_24h":65,"o3_8h":57,"o3_8h_24h":57,"pm10":0,"pm10_24h":0,"pm2_5":14,"pm2_5_24h":67,"quality":"优","level":"一级","so2":12,"so2_24h":36,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":29,"area":"义乌","co":0.574,"co_24h":1.02,"no2":43,"no2_24h":65,"o3":30,"o3_24h":30,"o3_8h":10,"o3_8h_24h":10,"pm10":26,"pm10_24h":91,"pm2_5":20,"pm2_5_24h":75,"quality":"优","level":"一级","so2":9,"so2_24h":7,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":30,"area":"临汾","co":1.835,"co_24h":1.946,"no2":3,"no2_24h":10,"o3":67,"o3_24h":69,"o3_8h":60,"o3_8h_24h":60,"pm10":20,"pm10_24h":45,"pm2_5":6,"pm2_5_24h":24,"quality":"优","level":"一级","so2":5,"so2_24h":12,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":30,"area":"锦州","co":0.56,"co_24h":0.77,"no2":6,"no2_24h":20,"o3":79,"o3_24h":80,"o3_8h":60,"o3_8h_24h":65,"pm10":24,"pm10_24h":41,"pm2_5":7,"pm2_5_24h":23,"quality":"优","level":"一级","so2":17,"so2_24h":61,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":31,"area":"宁波","co":0.973,"co_24h":1.519,"no2":42,"no2_24h":71,"o3":47,"o3_24h":49,"o3_8h":19,"o3_8h_24h":20,"pm10":30,"pm10_24h":87,"pm2_5":22,"pm2_5_24h":66,"quality":"优","level":"一级","so2":11,"so2_24h":18,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":32,"area":"鞍山","co":1.671,"co_24h":1.972,"no2":5,"no2_24h":16,"o3":62,"o3_24h":63,"o3_8h":51,"o3_8h_24h":52,"pm10":31,"pm10_24h":44,"pm2_5":11,"pm2_5_24h":21,"quality":"优","level":"一级","so2":18,"so2_24h":48,"primary_pollutant":"","time_point":"2014-01-08T14:00:00Z"},{"aqi":32,"area":"舟山","co":0.503,"co_24h":0.912,"no2":9,"no2_24h":53,"o3":90,"o3_24h":235,"o3_8h":63,"o3_8h_2
|