1.引入echarts
2.从dataV上获取相应省市数据:以石家庄为例
3.上代码
var chartDom = document.getElementById('map');
var myChart = echarts.init(chartDom);
var option;
$.get('https://geo.datav.aliyun.com/areas_v3/bound/geojson?code=130100_full',function(geoJson){
echarts.registerMap('SJZ', geoJson);
myChart.setOption(
(option = {
series: [
{
name:'石家庄市',
type: 'map',
map: 'SJZ'
}
]
})
)
})
4.地图背景图
1>
var domImg = document.getElementById('imgview');
html中引用id未imgview的img 或 domImg.src = '';
2>series
itemStyle:{
normal: {
areaColor: {
image: domImg,//配置图片
repeat: 'repeat'//可选值repeat、no-repeat、repeat-x、repeat-y
},
}
}