0

我正在使用 Google Maps api v3 .. 根据此文档,我可以像示例中那样获得任意 2 点之间的路径。

不是我想使用 VB.Net 获得相同的结果。我想在服务器端处理中获得相同的结果(意味着想要获得路径 [lat lon 对])。

我已经尝试过使用代码

  Dim lat As Double = 17.38489
        Dim lon As Double = 78.486939

        Dim lat2 As Double = 20.296095
        Dim lon2 As Double = 85.82459

        'For counter As Integer = 0 To 1
        Try

            Dim myURL As String = "http://maps.googleapis.com/maps/api/directions/json?origin=" & lat.ToString("0.000000") & "," & lon.ToString("0.000000") & "&destination=" & lat2.ToString("0.000000") & "," & lon2.ToString("0.000000") & "&sensor=false"
            Dim myRequest As HttpWebRequest = WebRequest.Create(myURL)

            myRequest.Method = "GET"

            ' Add request headers
            myRequest.KeepAlive = True
            myRequest.Accept = "*/*"
            myRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;)"
            myRequest.Headers.Add("Accept-Language: en-us")
            myRequest.Referer = "http://www.google.com/mapmaker?ll=16.303005,81.05464&spn=0.021583,0.040684&z=15"
            myRequest.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-sg")
            'myRequest.ContentType = "application/x-www-form-urlencoded"

            Dim c As Char = "c"

            Dim sb As New StringBuilder()

            ' Send the request and get the response
            Dim myResponse As HttpWebResponse = myRequest.GetResponse

            Dim reader As StreamReader = New StreamReader(myResponse.GetResponseStream())
            sb.Append(reader.ReadToEnd())
            reader.Close()
            myResponse.Close()

            Dim s As String = sb.ToString()

            Dim ds As String = s
            Response.Write(s)
        Catch ex As Exception

        End Try

谁能帮我吗..

4

1 回答 1

0

我相当肯定做这个服务器端违反了服务条款?此外,可以从 IP 地址发出多少请求是有限制的。如果超过这个限制会发生什么?您需要检查来自 Google 的错误消息并优雅地处理它们。如果您为服务付费,那么限制可能会更少。

于 2013-07-11T19:27:34.047 回答