#region 根据经纬度 获取地址信息 BaiduApi ////// 根据经纬度 获取 地址信息 /// /// 经度 /// 纬度 ///public static BaiDuGeoCoding GeoCoder(string lat, string lng) { string url = string.Format(WeiXinConst.Baidu_GeoCoding_ApiUrl, lat, lng); var model = HttpClientHelper.GetResponse (url); return model; } #endregion
BaiduGeoCoding是针对Api相应结果封装的对象:
public class BaiDuGeoCoding
{
public int Status { get; set; }
public Result Result { get; set; }
}
public class Result
{
public Location Location { get; set; }
public string Formatted_Address { get; set; }
public string Business { get; set; }
public AddressComponent AddressComponent { get; set; }
public string CityCode { get; set; }
}
public class AddressComponent
{
///
/// 省份
///
public string Province { get; set; }
///
/// 城市名
///
public string City { get; set; }
///
/// 区县名
///
public string District { get; set; }
///
/// 街道名
///
public string Street { get; set; }
public string Street_number { get; set; }
}
public class Location
{
public string Lng { get; set; }
public string Lat { get; set; }
}调用:
//需配置 WeiXineConst的BaiduAk string lat = "31.1430"; //经度 string lng = "121.2943";// 纬度 var model = WeiXinHelper.GeoCoder(lat, lng);
上一篇:小程序有哪些新功能
下一篇:微信支付开发之如何实现账单