コード例 #1
0
ファイル: GoogleGeocoder.cs プロジェクト: macrodepy/Geocoder
        public ResponseData Geocode(RequestData requestData)
        {
            var resp = new ResponseData();

            string url = "https://maps.googleapis.com/maps/api/geocode/xml?address={0}&key={1}";

            WebResponse response = null;

            try
            {
                url = string.Format(url, requestData.Address, GoogleGeocodeApiKey);
                var request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                response = request.GetResponse();

                using (var reader = new StreamReader(response.GetResponseStream()))
                {
                    resp.Data = reader.ReadToEnd();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
            }

            return resp;
        }
コード例 #2
0
ファイル: YandexGeocoder.cs プロジェクト: macrodepy/Geocoder
        public ResponseData Geocode(RequestData requestData)
        {
            var resp = new ResponseData();

            string url = "http://geocode-maps.yandex.ru/1.x/?geocode={0}&lang=tr-TR";

            WebResponse response = null;
            try
            {
                url = string.Format(url, requestData.Address);
                var request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                response = request.GetResponse();

                using (var reader = new StreamReader(response.GetResponseStream()))
                {
                    resp.Data = reader.ReadToEnd();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
            }

            return resp;
        }