根据官网的案例套用研究了一下,其中还有一部分代码不是很明白,希望能帮到有需要的朋友
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Documenttitle>
<script src="jquery.min.js">script>
<script src="echarts.min.js">script>
<script src="beijing.js">script>
head>
<body>
<div class="wrap" style="position: relative;">
<div id="map" style="width: 100%; height: 800px;">div>
div>
<script>
var myChart = echarts.init(document.getElementById('map'));
var geoCoordMap = {
"东城区": [116.418757, 39.937544],
"西城区": [116.366794, 39.910309],
"朝阳区": [116.486409, 39.991489],
"丰台区": [116.286968, 39.863642],
"石景山区": [116.170445, 39.974601],
"海淀区": [116.280316, 40.039074],
"门头沟区": [115.905381, 40.009183],
"房山区": [115.701157, 39.735535],
"通州区": [116.758603, 39.802486],
"顺义区": [116.753525, 40.128936],
"昌平区": [116.235906, 40.318085],
"大兴区": [116.338033, 39.658908],
"怀柔区": [116.607122, 40.524272],
"平谷区": [117.112335, 40.244783],
"密云区": [116.943352, 40.477362],
"延庆区": [115.985006, 40.465325]
};
var rawData = [
["朝阳区",10,20,30],
["丰台区",10,20,30],
["石景山区",10,20,30],
["海淀区",10,20,30],
["门头沟区",10,20,30],
["房山区",10,20,30],
["通州区",10,20,30],
["顺义区",10,20,30],
["昌平区",10,20,30],
["大兴区",10,20,30],
["怀柔区",10,20,30],
["平谷区",10,20,30],
["密云区",10,20,30],
["延庆区",10,20,30]
];
function makeMapData(rawData) {
var mapData = [];
for (var i = 0; i var geoCoord = geoCoordMap[rawData[i][0]];
if (geoCoord) {
mapData.push({
name: rawData[i][0],
value: geoCoord.concat(rawData[i].slice(1))
});
}
}
return mapData;
};
option = {
animation: false,
backgroundColor: new echarts.graphic.RadialGradient(0.5, 0.5, 0.4, [{
offset: 0,
color: '#4b5769'
}, {
offset: 1,
color: '#404a59'
}]),
tooltip: {
trigger: 'axis'
},
geo: {
map: '北京',
roam: true,
zoom: 1.155,
center: [116.366794, 40.400309],
label: {
emphasis: {
show: false,
areaColor: '#eee'
}
},
itemStyle: {
normal: {
areaColor: '#55C3FC',
borderColor: '#fff'
},
emphasis: {
areaColor: '#21AEF8'
}
}
},
series: []
};
function renderEachCity() {
var option = {
xAxis: [],
yAxis: [],
grid: [],
series: []
};
希望能帮到有需要的朋友,也希望有大神能帮我解答一下前边的几个封装方法的作用