/// <summary> /// 逆地理编码服务 /// </summary> /// <param name="location">坐标地址</param> /// <returns></returns> public Result <ReverseGeocodingReuslt> GetGeocoder(string location) { var checkMap = CheckMapKey(); if (!checkMap.IsSuccess) { return(Result <ReverseGeocodingReuslt> .InnerError(checkMap.ErrorMessage)); } Dictionary <string, string> querystringArrays = new Dictionary <string, string> { { "ak", MapAk }, { "location", location }, { "output", OutputString }, { "timestamp", AksnCaculater.GetTimeStamp() } }; querystringArrays.Add("sn", AksnCaculater.CaculateAKSN(MapAk, MapSk, MapGeocoderUrl, querystringArrays)); var url = MapHost + MapGeocoderUrl + "?" + AksnCaculater.HttpBuildQuery(querystringArrays); var result = HttpRequestHelper.SendRequest(url); if (!result.IsSuccess) { return(Result <ReverseGeocodingReuslt> .LogicError(result.ErrorMessage)); } ReverseGeocoding reverseGeocoding = result.Data.JsonToObj <ReverseGeocoding>(); return(reverseGeocoding.Status == 0 ? Result <ReverseGeocodingReuslt> .Success(reverseGeocoding.Result ?? new ReverseGeocodingReuslt()) : Result <ReverseGeocodingReuslt> .LogicError(reverseGeocoding.Message)); }
/// <summary> /// 坐标取地址 /// </summary> /// <param name="location"></param> /// <returns></returns> public string Test(string location) { string _Address = ""; ReverseGeocoding gd = new ReverseGeocoding(new ReverseGeocodingParam() { ak = "", callback = "", coordtype = "wgs84ll", location = location, output = "json", pois = 0, sn = "" } ); ReverseGeocoderResultModel gdresult = gd.GetGeocoderResult(); _Address = GetAddress(gdresult); return(_Address + "<br/><br/>" + Serializer.ToJson(gdresult)); }
private string GetAddressByGPS(string gps) { if (gps.Contains("|")) { gps = string.Join(",", gps.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)); } string _Address = string.Empty; var gd = new ReverseGeocoding(new ReverseGeocodingParam() { ak = "", callback = "", coordtype = "", location = gps, output = "json", pois = 0, sn = "" }); ReverseGeocoderResultModel gdresult = gd.GetGeocoderResult(); _Address = GetAddress(gdresult); return(_Address); }