示例#1
0
        public async Task <BaiduLocation> GeoLoc2GPS(string addr)
        {
            BaiduLocation re      = new BaiduLocation();
            var           request = new BaiduGeocodingRequest();

            request.address = addr;
            request.ak      = ak;
            request.city    = "上海市";
            var response = await GeocodingService.GetBaiduResponseAsync(request);

            if (response.result != null)
            {
                var result = Convert2GPS(response.result.location.lat, response.result.location.lng);
                re.lat = result[0];
                re.lng = result[1];
                return(re);
            }
            else
            {
                return(null);
            }
        }
        public static async Task <BaiduGeocodingResponse> GetBaiduResponseAsync(BaiduGeocodingRequest request)
        {
            var url = new Uri(BaiduApiUrl, request.ToUri());

            return(await Http.Get(url).As <BaiduGeocodingResponse>());
        }