设置需要链接的城市名称对象数组
//01.省市需要添加链接的城市.按格式复制; var provinceData = [ {"cityName": "宁波市"}, {"cityName": "台州市"}, {"cityName": "呼伦贝尔市"} ];
进入对应的城市后,添加myChart.on(“click”, function (params) {}事件。
if (pName === "china") { // 全国时,添加click 进入省级 myChart.on('click', function (param) { if (param.data && param.data.provinceKey) { if (provinceData.length) { $('#back').removeClass('hidden'); // 遍历取到provincesText 中的下标 去拿到对应的省js for (var i = 0; i < provincesText.length; i++) { if (param.name === provincesText[i]) { mapName = provincesText[i]; //显示对应省份的方法 showProvince(provinces[i], provincesText[i]); break; } } } } }); } else {//02.进入省份,匹配链接地址; myChart.on("click", function (params) { var subSystem = params.name; console.log(subSystem); if (params.name == "宁波市") { getWin('https://www.baidu.com/s?tn=baiduhome_pg&wd=' + params.name); } if (params.name == "台州市") { getWin('https://www.baidu.com/s?tn=baiduhome_pg&wd=' + params.name); } if (params.name == "呼伦贝尔市") { getWin('https://www.baidu.com/s?tn=baiduhome_pg&wd=' + params.name); } }); }
Done!