var _url = '/templates/definequery.php'; var _province = ""; var mychart = echarts.init(document.getelementbyid('china-map')); var oback = document.getelementbyid("back"); var seriesdata = [{name: '北京',value: 100}, {name: '天津',value: 0}, {name: '上海',value: 60}, {name: '重庆',value: 0}, {name: '河北',value: 60}, {name: '河南',value: 60}, {name: '云南',value: 0}, {name: '辽宁',value: 0}, {name: '黑龙江',value: 0}, {name: '湖南',value: 60}, {name: '安徽',value: 0}, {name: '山东',value: 60}, {name: '新疆',value: 0}, {name: '江苏',value: 0}, {name: '浙江',value: 0}, {name: '江西',value: 0}, {name: '湖北',value: 60}, {name: '广西',value: 60}, {name: '甘肃',value: 0}, {name: '山西',value: 60}, {name: '内蒙古',value: 0}, {name: '陕西',value: 0}, {name: '吉林',value: 0}, {name: '福建',value: 0}, {name: '贵州',value: 0}, {name: '广东',value: 597}, {name: '青海',value: 0}, {name: '西藏',value: 0}, {name: '四川',value: 60}, {name: '宁夏',value: 0}, {name: '海南',value: 60}, {name: '台湾',value: 0}, {name: '香港',value: 0}, {name: '澳门',value: 0},{name: '钓鱼岛',value: 0}]; oback.onclick = function () { initecharts("china", "点击省份,查看分公司联系方式"); }; initecharts("china", "点击省份,查看分公司联系方式"); // 初始化echarts function initecharts(pname, chinese_) { var tmpseriesdata = pname === "china" ? seriesdata : []; var option = { title: { text: chinese_ || pname, left: 'center' }, tooltip: { trigger: 'item', formatter: '{b}' }, series: [ { name: chinese_ || pname, type: 'map', maptype: pname, roam: false,//是否开启鼠标缩放和平移漫游 data: tmpseriesdata, top: "3%",//组件距离容器的距离 zoom:1.1, selectedmode : 'single', label: { normal: { //显示省份标签标签字体颜色 show: true, textstyle:{color:"#342d10"} }, //对应的鼠标悬浮效果 emphasis: { show: true, textstyle:{color:"#323232"} } }, itemstyle: { //区域:边框宽度、边框颜色、颜色 normal: { borderwidth: .5, bordercolor: '#0550c3', areacolor:"#4ea397", }, emphasis: { borderwidth: .5, bordercolor: '#4b0082', areacolor:"#ece39e", } }, } ] }; mychart.setoption(option); mychart.off("click"); // 添加click if (pname === "china") { mychart.on('click', function (param) { if(param.name=="" || param.name==null)param.name="南海诸岛"; if(_province==param.name){ _province=""; }else{ _province=param.name; } tolist(_province); }); } else { // 省份 mychart.on("dblclick", function () { initecharts("china", "中国"); }); } } function tolist(_province=""){ $.ajax({ url:_url, type:'post', datatype:'json', data:{'_province':_province,'action':'ajxa_province'}, success:function(res){ var html = ""; $.each(res.list,function(k,v){ html +='
'; html +='
'; html +=' '; html +=''+v.corporate+''; html +='
'; html +='
'; html +=' '; html +=''+v.phone+''; html +='
'; html +='
'; html +=' '; html +=''+v.fax+''; html +='
'; html +='
'; html +=' '; html +=''+v.email+''; html +='
'; html +='
'; html +=' '; html +=''+v.region+''; html +='
'; html +='
'; html +=' '; html +=''+v.address+''; html +='
'; html +='
'; }); $('#list').html(html); }, error:function(res){}, }); } tolist(); function showprovince(pname, chinese_) {}