C# 如何发布谷歌距离矩阵参数?

C# 如何发布谷歌距离矩阵参数?,c#,web-services,google-maps,google-maps-api-3,C#,Web Services,Google Maps,Google Maps Api 3,谷歌距离矩阵最多可以接受100个参数。但是使用GET-Ruquest url lenth将其限制在

谷歌距离矩阵最多可以接受100个参数。但是使用GET-Ruquest url lenth将其限制在<15个字符(我认为是2048个字符),并且我得到了错误414-请求的url太大,无法处理。因此,我认为有必要使用POST方法。但我不能。我的请求被拒绝了。那么我如何使用这项服务呢

    public static bool GetMatrix(string origins, string destinations)
    {
        string poststring = string.Format("origins={0}&destinations={1}&mode=bicycling&language=fr-FR&sensor=false", origins, destinations);
        byte[] postdata = Encoding.UTF8.GetBytes(poststring);

        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://maps.googleapis.com/maps/api/distancematrix/xml");
        webRequest.Method = "POST";
        webRequest.ContentType = "application/xml"; // or any other type dont work
        webRequest.ContentLength = postdata.Length;
        using (Stream writer = webRequest.GetRequestStream())
            writer.Write(postdata, 0, postdata.Length);

        using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
        {
            //Only for debug
            using (var stream = new StreamReader(webResponse.GetResponseStream()))
                System.Diagnostics.Debug.WriteLine(stream.ReadToEnd());

            return (webResponse.StatusCode == HttpStatusCode.OK);
        }
    }

JS方法

例如

C#不使用google.com计算距离的方法

 public decimal calcDistance(decimal latA, decimal longA, decimal latB, decimal longB)
    {

        double theDistance = (Math.Sin(DegreesToRadians(latA)) *
                Math.Sin(DegreesToRadians(latB)) +
                Math.Cos(DegreesToRadians(latA)) *
                Math.Cos(DegreesToRadians(latB)) *
                Math.Cos(DegreesToRadians(longA - longB)));

        return Convert.ToDecimal((RadiansToDegrees(Math.Acos(theDistance)))) * 69.09M * 1.6093M;
    }

试试谷歌地图jssdk吧。谢谢!但是我不知道js以及如何在C#中使用它。。。我需要学习它。。。2.我不需要套房,因为我需要的是公路距离,而不是直达距离。奇怪的是,POST方法没有解决方案……请检查js实现
 public decimal calcDistance(decimal latA, decimal longA, decimal latB, decimal longB)
    {

        double theDistance = (Math.Sin(DegreesToRadians(latA)) *
                Math.Sin(DegreesToRadians(latB)) +
                Math.Cos(DegreesToRadians(latA)) *
                Math.Cos(DegreesToRadians(latB)) *
                Math.Cos(DegreesToRadians(longA - longB)));

        return Convert.ToDecimal((RadiansToDegrees(Math.Acos(theDistance)))) * 69.09M * 1.6093M;
    }