Baidu interface to understand:
Http://lbsyun.baidu.com/index.php?title=webapi/route-matrix-api-v2
The starting and ending points are many-to-many relationships, and if you only want to take two coordinates, take one coordinate.
The following method has been tested to obtain the correct data. The method is not finished, you turn the JSON data
<summary>/////</summary>//<param Name= "Origins" > Start-point coordinates </par am>//<param name= "destinations" > Terminal coordinates </param>//<returns></returns> PU Blic static string Getdistance (string origins, String destinations) {try {// Test Data Origins = "22.823331,108.326998"; Destinations = "22.832541,108.321788|22.83841,108.294974|22.817868,108.425637|22.883959,108.305368| 22.83334,108.32637 "; Driving distance String url = "Http://api.map.baidu.com/routematrix/v2/driving"; string ak = "595ercihja0mg4tmhtm5ak58m00bqand"; string param = string. Format ("Origins={0}&destinations={1}&output=json&ak={2}", Origins, destinations, AK); String strurl = URL + '? ' + param; System.Net.HttpWebRequest request; Request = (System.Net.HttpWebReQuest) WebRequest.Create (strURL); Request. Method = "GET"; System.Net.HttpWebResponse response; Response = (System.Net.HttpWebResponse) request. GetResponse (); System.IO.Stream s; s = Response. GetResponseStream (); String strdate = ""; string strvalue = ""; StreamReader Reader = new StreamReader (s, Encoding.UTF8); while ((strdate = Reader.readline ()) = null) {strvalue + = strdate + "\ r \ n"; } return strvalue; } catch (Exception) {} return ""; }
Baidu map get two-point drive distance (non-linear distance) C #