//定义全国省份的数组(对应js文件名)
            var provinces = ['shanghai', 'hebei','shanxi','neimenggu','liaoning','jilin','heilongjiang','jiangsu','zhejiang','anhui','fujian','jiangxi','shandong','henan','hubei','hunan','guangdong','guangxi','hainan','sichuan','guizhou','yunnan','xizang','shanxi1','gansu','qinghai','ningxia','xinjiang', 'beijing', 'tianjin', 'chongqing', 'xianggang', 'aomen', 'taiwan'];

            var provincesText = ['上海', '河北', '山西', '内蒙古', '辽宁', '吉林','黑龙江',  '江苏', '浙江', '安徽', '福建', '江西', '山东','河南', '湖北', '湖南', '广东', '广西', '海南', '四川', '贵州', '云南', '西藏', '陕西', '甘肃', '青海', '宁夏', '新疆', '北京', '天津', '重庆', '香港', '澳门', '台湾'];

            //遍历取到provincesText 中的下标  去拿到对应的省js
            for(var  i= 0 ; i < provincesText.length ; i++ ){
                if(params.name == provincesText[i]){
                    //显示对应省份的方法
                    showProvince(provinces[i],provincesText[i])
                    break ;
                }
            }

            //展示对应的省(渲染市级地图)
            function  showProvince(pName, Chinese_){
                //后台获取数据
                $.get("{:url('DbList/mapDb')}").done(function (data) {
                    console.log(data);
                    // console.log(data.listAdress1b);
                    //这写省份的js都是通过在线构建工具生成的,保存在本地,需要时加载使用即可
                    loadBdScript('$'+pName+'JS','/static/js/province/'+pName+'.js',function(){

                        initEchartsMap(Chinese_,data.listAdress1b) ;
                    });
});

            }

            //加载对应的JS
            function loadBdScript(scriptId, url, callback) {
                var script = document.createElement("script")
                script.type = "text/javascript";
                if (script.readyState){  //IE
                    script.onreadystatechange = function(){
                        if (script.readyState == "loaded" || script.readyState == "complete"){
                            script.onreadystatechange = null;
                            callback();
                        }
                    };
                } else {  //Others
                    script.onload = function(){
                        callback();
                    };
                }
                script.src = url;
                script.id = scriptId;
                document.getElementsByTagName("head")[0].appendChild(script);
            };
        });

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注