as a result of project requirements, use the Echarts control to complete the map drilling function in Shandong Province, now put the method paste;
Randomly generated data function of provinces and cities Randomdata () {return Math.Round (Math.random () *50);}
Map under drill Use switch convert map JSON file var mapchange=function (city) {var maps= ' Shandong ';
Switch (city) {case ' Jinan ': maps= ' Jinan ';
Case ' Dezhou ': maps= ' Dezhou ';
Case ' Taian ': maps= ' Taian ';
Case ' Yantai ': maps= ' Yantai ';
Case ' Zibo ': maps= ' Zibo ';
Case ' Laiwu ': maps= ' Laiwu ';
Case ' Rizhao ': maps= ' Rizhao ';
Case ' Jining ': maps= ' jining ';
Case ' Heze ': maps= ' heze ';
Case ' Weihai ': maps= ' Weihai ';
Case ' Zaozhuang ': maps= ' Zaozhuang ';
Case ' Linyi ': maps= ' Linyi ';
Case ' Binzhou ': maps= ' Binzhou ';
Case ' Dongying ': maps= ' dongying ';
Case ' Weifang ': maps= ' Weifang ';
Case ' Liaocheng ': maps= ' Liaocheng ';
Case ' Qingdao ': maps= ' Qingdao ';
return maps;
};
Urban District methods var citymapsshow=function (city) {var chart = echarts.init (document.getElementById (' citymaps '));
Chart.showloading (); $.geT (' js/echarts/map/' +city+ '. Json ', function (Chinajson) {echarts.registermap (' Citymap ', Chinajson);
Chart.hideloading ();
Chart.setoption ({title: {text: ' Map of Shandong ', subtext: ' Charge pile dispatch ', Left: ' Left ', textstyle:{color: ' #fff ', fon
Tstyle: ' Normal ', fontweight: ' Normal ', fontFamily: ' XXFarEastFont-Arial ',
FONTSIZE:22}, subtextstyle:{color: ' White ',
FontStyle: ' Normal ', fontweight: ' Normal ', fontFamily: ' XXFarEastFont-Arial ',
Fontsize:16}}, Visualmap: {
min:0, max:200, left: ' 3% ', top: ' Bottom ', text:[' High ', ' low '],//text, default to numeric text calculable:true, textstyle:{
Color: ' White '}, tooltip: { Trigger: ' Item '}, Legend: {Orient: ' vertical ', left
: ' Right ', top: ' Bottom ', data:[' charging ', ' standby ', ' abnormal state '], textstyle:{
Color: ' #fff '}, Silent:false, series: [
{name: ' In charge ', type: ' Map ', map: ' Citymap ',
Roam:true, scalelimit:{min:1.2, Max:4}, Showlengendsymbol:true, Label: {normal: {show:true
, textstyle:{color: ' Blue ',}
}, emphasis: {show:true, textstyle:{
}
}
},
},
]
});
Chart.on ("DblClick", function (params) {var city=params.name;
Mapchange (city);
document.getElementById (' Province '). style.display= ' None ';
document.getElementById (' Citymaps '). style.display= ' block ';
});
});
};
Return to Shandong Province map Var provincemaps=function () {var chart = echarts.init (document.getElementById (' Province '));
Chart.showloading ();
$.get (' Js/echarts/map/shandong.json ', function (Chinajson) {echarts.registermap (' Shandong ', Chinajson);
Chart.hideloading ();
Chart.setoption ({title: {text: ' Map of Shandong '), Subtext: ' Charge pile dispatch ', left: ' Left ', textstyle:{color: ' #fff ', FontStyle: ' Normal ', fontweight: ' normal ', F
ontfamily: ' Song Body ', fontsize:22}, subtextstyle:{
Color: ' White ', FontStyle: ' Normal ', fontweight: ' Normal ',
fontFamily: ' Song Body ', Fontsize:16}},
Visualmap: {min:0, max:200, left: ' 3% ',
Top: ' Bottom ', text:[' high ', ' low '],//text, default to numeric text calculable:true,
textstyle:{color: ' White '},
ToolTip: { Trigger: ' Item '}, Legend: {Orient: ' vertical ', Left: "Right", top: ' Bottom ', data:[' in charge ', ' standby ', ' abnormal state ', TEXTST
yle:{color: ' #fff '}}, Silent:false,
Series: [{name: ' Charge ', type: ' Map ', map: ' Shandong ',
Roam:true, scalelimit:{Min:1, Max:4
}, Showlengendsymbol:true, Label: {normal: {
Show:true, textstyle:{color: ' Blue ',
}, emphasis: {show:true, TextStyle: {}}}, data:[{name: ' Jinan ', Value:randomdata ()}, {name: ' Dezhou ', Value:randomdata ()}, {name: ' Qingdao ', value: Randomdata ()},],}, {name: ' Standby ', type: ' Ma
P ', map: ' Shandong ', Roam:true, scalelimit:{Min:1,
Max:4}, showlengendsymbol:true, Label: { Normal: {show:true, textstyle:{color:
' Blue ',}, emphasis: {
Show:true, textstyle:{}}
}, data:[{name: ' Jinan ', Value:randomdata ()}, {name: ' Dezhou ', Value:randomdata ()},
{name: ' Qingdao ', Value:randomdata ()},],}, { Name: ' Exception state ', type: ' Map ', map: ' Shandong ', Roam:true, SC
alelimit:{min:1, Max:4}, Showlengendsymbol:true, Label: {normal: {show:true, TEXTST yle:{color: ' Blue ',}}
, emphasis: {show:true, textstyle:{ }}, data:[{name: ' Jinan ', VALUE:RANDOMD
ATA ()}, {name: ' Dezhou ', Value:randomdata ()}, {name: ' Qingdao ', Value:randomdata ()},],
},
]
});
Chart.on ("click", Function (params) {var city=params.name;
var city1=mapchange (city);
document.getElementById (' Province '). style.display= ' None ';
document.getElementById (' Citymaps '). style.display= ' block ';
Citymapsshow (city1);
});
}); };