Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        public static async Task <BaiduGeocodingResponse> GetBaiduResponseAsync(BaiduGeocodingRequest request)
        {
            var url = new Uri(BaiduApiUrl, request.ToUri());

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