// Get Village location: lat & lag from Baidu // http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-geocoding private LocationInfo GetNewVillageLocation(string villageName) { LocationInfo locationInfo = new LocationInfo(); try { string baiAk = "7UA0GQRgTDFVcQ8bnpA7LFsFiFQRIphS"; string getUrl = $"http://api.map.baidu.com/geocoding/v3/?address=重庆市{villageName}&output=json&ak={baiAk}"; string response = HttpRequestUtil.CreateGetHttpResponse(getUrl); RootObject rootObject = JsonConvert.DeserializeObject <RootObject>(response); // Update to the database if (rootObject.Status == 0) { locationInfo.VillageName = villageName; locationInfo.Lat = rootObject.Result.Location.Lat; locationInfo.Lng = rootObject.Result.Location.Lng; } Console.WriteLine(response); Console.WriteLine($"{DateTime.Now}: get location info from BaiDu Map for {villageName}."); } catch (Exception e) { Console.WriteLine(e); return(null); } return(locationInfo); }