C # background GPS coordinates converted into Baidu coordinates

Source: Internet
Author: User

protected void Page_Load (object sender, EventArgs e)
{

           
       //get current Latitude stringLatitude ="117.707677"; //Get current longitude stringLongitude ="39.084097"; //Baidu coordinate conversion API stringPath ="http://api.map.baidu.com/ag/coord/convert?from=0&to=4&x="+ Latitude +"&y="+ Longitude +""; HttpWebRequest WebRequest=(HttpWebRequest) webrequest.create (path); Webrequest.method="GET"; HttpWebResponse WebResponse=(HttpWebResponse) webrequest.getresponse (); StreamReader SR=NewStreamReader (WebResponse.GetResponseStream (), Encoding.UTF8); stringStrjson =Sr. ReadToEnd (); JavaScriptSerializer JS=NewJavaScriptSerializer (); Mapconvert MC= js. Deserialize<mapconvert>(Strjson); if(Mc.error = ="0") { stringLon =mc.x; stringLat =mc.y; //perform Base64 decoding byte[] Xbuffer =convert.frombase64string (LON); stringStrx = Encoding.UTF8.GetString (Xbuffer,0, xbuffer.length); byte[] Ybuffer =convert.frombase64string (LAT); stringStry = Encoding.UTF8.GetString (Ybuffer,0, xbuffer.length); stringStrB = Strx +","+Stry; } Else { stringStrB ="Get failed"; } } } Public classMapconvert { Public stringError {Get;Set; } Public stringx {Get;Set; } Public stringY {Get;Set; } }

C # background GPS coordinates converted into Baidu coordinates

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.