Пример #1
0
        /// <summary>
        /// 经纬度解析
        /// </summary>
        /// <param name="Longitude">精度</param>
        /// <param name="Latitude">纬度</param>
        /// <param name="CallType">响应方式</param>
        public BaiduLocation Getdistrict(string Longitude, string Latitude, string CallType)
        {
            var url         = "http://api.map.baidu.com/geocoder";
            var parameters1 = new Dictionary <string, string>();

            parameters1.Add("location", Latitude + "," + Longitude);//维度加精度
            parameters1.Add("output", CallType);
            parameters1.Add("key", "8K08CxWScbFV7BKKarcevPq9LWBaVAUj");
            var result      = _http.HttpSend(url, parameters1, "post");
            var baiduResult = JsonMethod.JsonToModel <BaiduLocation>(result);

            return(baiduResult);
        }
Пример #2
0
        /// <summary>
        /// 根据名称获取天气
        /// </summary>
        /// <param name="cityName"></param>
        /// <returns></returns>
        public WeatherInfo GetWeatherInfo(string cityName)
        {
            var url         = "http://wthrcdn.etouch.cn/WeatherApi";
            var parameters2 = new Dictionary <string, string>();

            parameters2.Add("city", cityName);
            var weatherXML  = _http.HttpSend(url, parameters2, "post").ToString();
            var weatherInfo = new WeatherInfo();
            var doc         = new XmlDocument();

            doc.LoadXml(weatherXML);
            var weatherJson = JsonMethod.XmlToJSON(doc);

            weatherInfo = JsonMethod.JsonToModel <WeatherInfo>(weatherJson);

            return(weatherInfo);
        }