/// <summary>
        /// 执行地图查询.
        /// </summary>
        private void DoMapQuery()
        {
            AliyunMapServuce      service = new AliyunMapServuce();
            AliyunGeocodingResult result  = service.Geocoding(this.txtAddress.Text);

            this.lon = result.lon;
            this.lat = result.lat;
        }
Example #2
0
        public AliyunGeocodingResult Geocoding(string addressName)
        {
            string url = BASE_URL + System.Web.HttpUtility.UrlEncode(addressName, Encoding.UTF8);


            //访问该链接
            WebRequest wrt = WebRequest.Create(url);
            //获得返回值
            WebResponse wrs = wrt.GetResponse();
            // 从 Internet 资源返回数据流。
            Stream s = wrs.GetResponseStream();
            // 构造 序列化类.
            DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(AliyunGeocodingResult));
            // 读取结果.
            AliyunGeocodingResult result = (AliyunGeocodingResult)dcjs.ReadObject(s);

            // 返回.
            return(result);
        }