Example #1
0
        private static mapv3 GetHttpRequest(string areaAddress)
        {
            HttpClient httpClient = new HttpClient {
                BaseAddress = new Uri("http://api.map.baidu.com/")
            };
            HttpResponseMessage httpResponseMessage = httpClient.GetAsync("geocoding/v3/?address=" + areaAddress + "&output=json&ak=你的key").GetAwaiter().GetResult();
            var   result = httpResponseMessage.Content.ReadAsStringAsync().GetAwaiter().GetResult();
            mapv3 data   = JsonConvert.DeserializeObject <mapv3>(result);

            return(data);
        }
Example #2
0
        private static void fullPoint(EchartsModel echartsModel, string name, string where, int confirm)
        {
            if (!dic.Keys.Contains(name))
            {
                mapv3 mapv3 = GetHttpRequest(where).Result;
                if (mapv3.status == 0)
                {
                    var      location = mapv3.result.location;
                    double[] d        = new double[] { location.lng, location.lat };
                    dic.Add(name, d);
                }
            }
            //后续需要优化部分
            EchartsModel echartsModelClone = (EchartsModel)echartsModel.clone();

            echartsModelClone.name  = name;
            echartsModelClone.value = confirm;
            echartsModels.Add(echartsModelClone);
        }
Example #3
0
        private static void GetPositionOfJson(IList <AreaTree> areaTrees)
        {
            // 考虑到查询成本
            echartsModels    = new List <EchartsModel>();
            echartsMapModels = new List <EchartsMapModel>();
            pronvincedic     = new List <EchartsModel>();
            EchartsModel    echartsModel    = new EchartsModel();
            EchartsMapModel echartsMapModel = new EchartsMapModel();

            foreach (var country in areaTrees)
            {
                var CountryName = country.Name;
                if (CountryName != "中国")
                {
                    //only china 其他国家不管
                    continue;
                }
                var provinceRank = "省";
                foreach (var province in country.Children)
                {
                    if (province.Name == "北京" || province.Name == "天津" || province.Name == "上海" || province.Name == "重庆")
                    {
                        provinceRank = "市";
                    }
                    var provinceName = province.Name + provinceRank;

                    //加入统计 因为西藏省区
                    if (!dic.Keys.Contains(province.Name))
                    {
                        var   fullName = provinceName + province.Name;
                        mapv3 mapv3    = GetHttpRequest(fullName);
                        if (mapv3.status == 0)
                        {
                            var      location = mapv3.result.location;
                            double[] d        = new double[] { location.lng, location.lat };
                            dic.Add(province.Name, d);
                        }
                    }
                    EchartsModel echartsModelPClone = (EchartsModel)echartsModel.clone();
                    echartsModelPClone.name  = province.Name;
                    echartsModelPClone.value = province.Total.Confirm;
                    pronvincedic.Add(echartsModelPClone);


                    //颜色
                    EchartsMapModel echartsMapModelClone = (EchartsMapModel)echartsMapModel.clone();
                    echartsMapModelClone.name = province.Name;
                    //总感染人数
                    EchartsModel InfectSum = (EchartsModel)echartsModel.clone();
                    InfectSum.name  = "感染人数";
                    InfectSum.value = province.Total.Confirm;
                    //治愈人数
                    EchartsModel CureSum = (EchartsModel)echartsModel.clone();
                    CureSum.name  = "治愈人数";
                    CureSum.value = province.Total.Heal;
                    //沉重的死亡人数
                    EchartsModel HeadSum = (EchartsModel)echartsModel.clone();
                    HeadSum.name  = "死亡人数";
                    HeadSum.value = province.Total.Dead;
                    List <EchartsModel> echartsModelMapList = new List <EchartsModel>();
                    echartsModelMapList.Add(InfectSum);
                    echartsModelMapList.Add(CureSum);
                    echartsModelMapList.Add(HeadSum);
                    echartsMapModelClone.value = echartsModelMapList;
                    echartsMapModels.Add(echartsMapModelClone);
                    foreach (var city in province.children)
                    {
                        if (!dic.Keys.Contains(city.Name))
                        {
                            var   fullName = provinceName + city.Name;
                            mapv3 mapv3    = GetHttpRequest(fullName);
                            if (mapv3.status == 0)
                            {
                                var      location = mapv3.result.location;
                                double[] d        = new double[] { location.lng, location.lat };
                                dic.Add(city.Name, d);
                            }
                        }
                        //后续需要优化部分
                        EchartsModel echartsModelClone = (EchartsModel)echartsModel.clone();
                        echartsModelClone.name  = city.Name;
                        echartsModelClone.value = city.Total.Confirm;
                        echartsModels.Add(echartsModelClone);
                    }
                }
            }
        }