html部分
<div class="menu">
<span class="name">吉林省</span>
</div>
<div id="main" style="width: 100%;height:669px;">
</div>
js部分
var sheng = "省/吉林省.json"
var baicheng = "省/吉林省/白城市.json";
var daan = "省/吉林省/白城市/大安市.json";
var taobei = "省/吉林省/白城市/洮北区.json";
var taonan = "省/吉林省/白城市/洮南市.json";
var tongyu = "省/吉林省/白城市/通榆县.json";
var zhenlai = "省/吉林省/白城市/镇赉县.json";
var baishan = "省/吉林省/白山市.json";
var fusong = "省/吉林省/白山市/抚松县.json";
var hunjiang = "省/吉林省/白山市/浑江区.json";
var jiangyuan = "省/吉林省/白山市/江源区.json";
var jingyu = "省/吉林省/白山市/靖宇县.json";
var linjiang = "省/吉林省/白山市/临江市.json";
var cbcx = "省/吉林省/白山市/长白朝鲜族自治县.json";
var jilin = "省/吉林省/吉林市.json";
var changyi = "省/吉林省/吉林市/昌邑区.json";
var chuanying = "省/吉林省/吉林市/船营区.json";
var fengman = "省/吉林省/吉林市/丰满区.json";
var huadian = "省/吉林省/吉林市/桦甸市.json";
var jiaohe = "省/吉林省/吉林市/蛟河市.json";
var longtan = "省/吉林省/吉林市/龙潭区.json";
var panshi = "省/吉林省/吉林市/磐石市.json";
var shulan = "省/吉林省/吉林市/舒兰市.json";
var yongji = "省/吉林省/吉林市/永吉县.json";
var liaoyuan = "省/吉林省/辽源市.json";
var dongfeng = "省/吉林省/辽源市/东丰县.json";
var dongliao = "省/吉林省/辽源市/东辽县.json";
var longshan = "省/吉林省/辽源市/龙山区.json";
var xian = "省/吉林省/辽源市/西安区.json";
var siping = "省/吉林省/四平市.json";
var gongzhuling = "省/吉林省/四平市/公主岭市.json";
var lishu = "省/吉林省/四平市/梨树县.json";
var shuangliao = "省/吉林省/四平市/双辽市.json";
var tiedong = "省/吉林省/四平市/铁东区.json";
var tiexi = "省/吉林省/四平市/铁西区.json";
var ytm = "省/吉林省/四平市/伊通满族自治县.json";
var songyuan = "省/吉林省/松原市.json";
var fuyu = "省/吉林省/松原市/扶余市.json";
var ningjiang = "省/吉林省/松原市/宁江区.json";
var qgrlsm = "省/吉林省/松原市/前郭尔罗斯蒙古族自治县.json";
var qianan = "省/吉林省/松原市/乾安县.json";
var changling = "省/吉林省/松原市/长岭县.json";
var tonghuashi = "省/吉林省/通化市.json";
var dongchang = "省/吉林省/通化市/东昌区.json";
var erdaojiang = "省/吉林省/通化市/二道江区.json";
var huinan = "省/吉林省/通化市/辉南县.json";
var jian = "省/吉林省/通化市/集安市.json";
var liuhe = "省/吉林省/通化市/柳河县.json";
var meihekou = "省/吉林省/通化市/梅河口市.json";
var tonghuaxian = "省/吉林省/通化市/通化县.json";
var ybcx = "省/吉林省/延边朝鲜族自治州.json";
var antu = "省/吉林省/延边朝鲜族自治州/安图县.json";
var dunhua = "省/吉林省/延边朝鲜族自治州/敦化市.json";
var helong = "省/吉林省/延边朝鲜族自治州/和龙市.json";
var hunchun = "省/吉林省/延边朝鲜族自治州/珲春市.json";
var longjing = "省/吉林省/延边朝鲜族自治州/龙井市.json";
var tumen = "省/吉林省/延边朝鲜族自治州/图们市.json";
var wangqing = "省/吉林省/延边朝鲜族自治州/汪清县.json";
var yanji = "省/吉林省/延边朝鲜族自治州/延吉市.json";
var changchun = "省/吉林省/长春市.json";
var chaoyang = "省/吉林省/长春市/朝阳区.json";
var dehui = "省/吉林省/长春市/德惠市.json";
var erdao = "省/吉林省/长春市/二道区.json";
var jiutai = "省/吉林省/长春市/九台区.json";
var kuancheng = "省/吉林省/长春市/宽城区.json";
var lvyuan = "省/吉林省/长春市/绿园区.json";
var nanguan = "省/吉林省/长春市/南关区.json";
var nongan = "省/吉林省/长春市/农安县.json";
var shuangyang = "省/吉林省/长春市/双阳区.json";
var yushu = "省/吉林省/长春市/榆树市.json";
var cityName = {
"吉林省": sheng,
"白城市": baicheng,
"大安市": daan,
"洮北区": taobei,
"洮南市": taonan,
"通榆县": tongyu,
"镇赉县": zhenlai,
"白山市": baishan,
"抚松县": fusong,
"浑江区": hunjiang,
"江源区": jiangyuan,
"靖宇县": jingyu,
"临江市": linjiang,
"长白朝鲜族自治县": cbcx,
"吉林市": jilin,
"昌邑区": changyi,
"船营区": chuanying,
"丰满区": fengman,
"桦甸市": huadian,
"蛟河市": jiaohe,
"龙潭区": longtan,
"磐石市": panshi,
"舒兰市": shulan,
"永吉县": yongji,
"辽源市": liaoyuan,
"东丰县": dongfeng,
"东辽县": dongliao,
"龙山区": longshan,
"西安区": xian,
"四平市": siping,
"公主岭市": gongzhuling,
"梨树县": lishu,
"双辽市": shuangliao,
"铁东区": tiedong,
"铁西区": tiexi,
"伊通满族自治县": ytm,
"松原市": songyuan,
"扶余市": fuyu,
"宁江区": ningjiang,
"前郭尔罗斯蒙古族自治县": qgrlsm,
"乾安县": qianan,
"长岭县": changling,
"通化市": tonghuashi,
"东昌区": dongchang,
"二道江区": erdaojiang,
"辉南县": huinan,
"集安市": jian,
"柳河县": liuhe,
"梅河口市": meihekou,
"通化县": tonghuaxian,
"延边朝鲜族自治州": ybcx,
"安图县": antu,
"敦化市": dunhua,
"和龙市": helong,
"珲春市": hunchun,
"龙井市": longjing,
"图们市": tumen,
"汪清县": wangqing,
"延吉市": yanji,
"长春市": changchun,
"朝阳区": chaoyang,
"德惠市": dehui,
"二道区": erdao,
"九台区": jiutai,
"宽城区": kuancheng,
"绿园区": lvyuan,
"南关区": nanguan,
"农安县": nongan,
"双阳区": shuangyang,
"榆树市": yushu
}
var data01 = [{
name: '白城市',
value: 10000
},
{
name: '松原市',
value: 1000
},
{
name: '长春市',
value: 6000
},
{
name: '四平市',
value: 200
},
{
name: '吉林市',
value: 50000
},
{
name: '辽源市',
value: 8000
},
{
name: '通化市',
value: 10
},
{
name: '白山市',
value: 10000
},
{
name: '延边朝鲜族自治州',
value: 700
},
];
var data21 = [{
name: '大安市',
value: 10000
},
{
name: '洮北区',
value: 1000
},
{
name: '洮南市',
value: 6000
},
{
name: '通榆县',
value: 200
},
{
name: '镇赉县',
value: 50000
},
];
var data22 = [{
name: '长岭县',
value: 10000
},
{
name: '扶余市',
value: 1000
},
{
name: '宁江区',
value: 6000
},
{
name: '前郭尔罗斯蒙古族自治县',
value: 200
},
{
name: '乾安县',
value: 2000
},
];
var data23 = [{
name: '朝阳区',
value: 10000
},
{
name: '德惠市',
value: 1000
},
{
name: '二道区',
value: 6000
},
{
name: '九台区',
value: 200
},
{
name: '宽城区',
value: 2000
},
{
name: '绿园区',
value: 10000
},
{
name: '南关区',
value: 1000
},
{
name: '农安县',
value: 6000
},
{
name: '双阳区',
value: 200
},
{
name: '榆树市',
value: 2000
},
];
cityCount = {
"吉林省": data01,
"白城市": data21,
"大安市": data01,
"洮北区": data01,
"洮南市": data01,
"通榆县": data01,
"镇赉县": data01,
"白山市": data01,
"抚松县": data01,
"浑江区": data01,
"江源区": data01,
"靖宇县": data01,
"临江市": data01,
"长白朝鲜族自治县": data01,
"吉林市": data01,
"昌邑区": data01,
"船营区": data01,
"丰满区": data01,
"桦甸市": data01,
"蛟河市": data01,
"龙潭区": data01,
"磐石市": data01,
"舒兰市": data01,
"永吉县": data01,
"辽源市": data01,
"东丰县": data01,
"东辽县": data01,
"龙山区": data01,
"西安区": data01,
"四平市": data01,
"公主岭市": data01,
"梨树县": data01,
"双辽市": data01,
"铁东区": data01,
"铁西区": data01,
"伊通满族自治县": data01,
"松原市": data22,
"扶余市": data01,
"宁江区": data01,
"前郭尔罗斯蒙古族自治县": data01,
"乾安县": data01,
"长岭县": data01,
"通化市": data01,
"东昌区": data01,
"二道江区": data01,
"辉南县": data01,
"集安市": data01,
"柳河县": data01,
"梅河口市": data01,
"通化县": data01,
"延边朝鲜族自治州": data01,
"安图县": data01,
"敦化市": data01,
"和龙市": data01,
"珲春市": data01,
"龙井市": data01,
"图们市": data01,
"汪清县": data01,
"延吉市": data01,
"长春市": data23,
"朝阳区": data01,
"德惠市": data01,
"二道区": data01,
"九台区": data01,
"宽城区": data01,
"绿园区": data01,
"南关区": data01,
"农安县": data01,
"双阳区": data01,
"榆树市": data01
}
// 基于准备好的dom,初始化echarts实例
// var myChart = echarts.init(document.getElementById('main'));
// function areaColor(data){
var myChart = echarts.init(document.getElementById('main'));
var option = {
dataRange: {
x: 'left',
y: 'bottom',
textStyle: {
color: '#88ceed',
fontSize: 14 //Y轴 字体大小
},
splitList: [{
start: 10000
},
{
start: 5000,
end: 10000
},
{
start: 1000,
end: 5000
},
{
start: 500,
end: 1000
},
{
start: 100,
end: 500
},
{
start: 0,
end: 100
}
],
color: ['#f35000', '#f39800', '#9977e4', '#2ec8ca', '#2063cc', '#284b83']
},
series: [{
type: 'map',
mapType: name,
label: {
normal: {
show: true
},
emphasis: {
textStyle: {
color: '#fff',
}
}
},
itemStyle: {
normal: {
color: "#fff",
borderColor: '#389BB7',
areaColor: '#fff',
backgroundColor: "#fff"
},
emphasis: {
areaColor: '#389BB7',
borderWidth: 0
}
},
animation: true,
data: data01
}]
}
// }
map(cityName['吉林省'], data01);
// areaColor(data01);
function map(url, data) {
// alert(cityName[name])
$.get(url, function(geoJson) {
echarts.registerMap(name, geoJson);
myChart.setOption(option);
});
var myChart = echarts.init(document.getElementById('main'));
var option = {
dataRange: {
x: 'left',
y: 'bottom',
textStyle: {
color: '#88ceed',
fontSize: 14 //Y轴 字体大小
},
splitList: [{
start: 10000
},
{
start: 5000,
end: 10000
},
{
start: 1000,
end: 5000
},
{
start: 500,
end: 1000
},
{
start: 100,
end: 500
},
{
start: 0,
end: 100
}
],
color: ['#f35000', '#f39800', '#9977e4', '#2ec8ca', '#2063cc', '#284b83']
},
series: [{
type: 'map',
mapType: name,
label: {
normal: {
show: true
},
emphasis: {
textStyle: {
color: '#fff'
}
}
},
itemStyle: {
normal: {
borderColor: '#389BB7',
areaColor: '#fff',
label: {
show: true,
color: "#000",
fontSize: 16,
backgroundColor: "rgba(255,255,255,.3)",
},
color: "rgba(255,255,255,.3)"
},
emphasis: {
areaColor: '#389BB7',
borderWidth: 0
}
},
animation: true,
data: data
}]
}
}
// 地图点击
myChart.on('click', function(e) {
console.log(e)
map(cityName[e.name], cityCount[e.name])
if(e.name != $('.menu span:last-child').text()) {
$('.menu').append('<span>></span><span class="name">' + e.name + '</span>')
}
})
// 地图导航点击
$('.menu').on('click', 'span.name', function() {
var area = $(this).text();
var ind = $(this).index();
for(var i = $('.menu span').length - 1; i > ind; i--) {
$('.menu span').eq(i).remove()
}
map(cityName[area], cityCount[area])
})