zoukankan      html  css  js  c++  java
  • 海王...O2O获取订单地址计算经纬度的方法

            /// <summary>
            /// 获取订单地址经纬度的方法  API
            /// </summary>
            /// <param name="address">订单地址</param>
            /// <param name="city">市</param>
            /// <returns></returns>

         public static string send(string address, string city)
            {
                //引入对应的命名空间...
                System.Net.HttpWebRequest request;
                request = (System.Net.HttpWebRequest)WebRequest.Create("http://api.map.baidu.com/geocoder?address=" + System.Web.HttpUtility.UrlEncode(address) + "&output=xml&key=6730e17525eb552282f7f08bcd9bb34d&city=" + System.Web.HttpUtility.UrlEncode(city));
                request.Method = "get";
                // request.Timeout = 10000;
                System.Net.HttpWebResponse response;
                response = (System.Net.HttpWebResponse)request.GetResponse();
                System.IO.Stream s; s = response.GetResponseStream();
                XmlTextReader Reader = new XmlTextReader(s);
                Reader.MoveToContent();
                string strValue = Reader.ReadInnerXml();
                strValue = strValue.Replace("&lt;", "<");
                strValue = strValue.Replace("&gt;", ">");
                Reader.Close();
                return strValue;
            }

    public   void    GetBestBranch()

     {

           //列:调用

          string xmlContent = string.Empty;

          xmlContent=类名.send(地址, 市);

          xml.LoadXml(xmlContent);

        //经度  和   纬度

        double   pointx = double.Parse((xml.LastChild.LastChild.SelectSingleNode("location")).SelectSingleNode("lat").InnerText);
        double   pointy = double.Parse((xml.LastChild.LastChild.SelectSingleNode("location")).SelectSingleNode("lng").InnerText);

    }

  • 相关阅读:
    2018年国内就业薪资高的7大编程语言排行
    前端css实现最基本的时间轴
    前端css实现最基本的时间轴
    用Canvas画一个刮刮乐
    用Canvas画一个刮刮乐
    「干货」从菜鸟到大神,前端学习书籍推荐
    洛谷P3379 【模板】最近公共祖先(LCA)
    洛谷 P1359 租用游艇
    位运算...
    洛谷P2782 友好城市
  • 原文地址:https://www.cnblogs.com/TanYong/p/5105210.html
Copyright © 2011-2022 走看看