您可能想查看 GoogleMaps Api:
Static Map API
Directions API
这些 API 为您提供 XML 响应,您可以在其中解析它们以显示结果。
我做了一个来查找时间和距离,您可以将其用作示例:
这是我早期的尝试之一,因此没有使用 XML,但它会让您了解如何处理来自 google 的响应。
Public Function GMap(origin_address As String, destination_address As String, Optional mode As Integer = 1, Optional datatype As Integer = 1)
Dim surl As String
Dim oXH As Object
Dim bodytxt As String
Dim time_e As String
Dim distanc_e As String
Dim strmode As String
If mode = 1 Then
strmode = "walking"
ElseIf mode = 2 Then
strmode = "driving"
ElseIf mode = 3 Then
strmode = "bicycling"
Else
GMap = "Invalid Mode"
Exit Function
End If
surl = "http://maps.googleapis.com/maps/api/distancematrix/xml?origins=;" & _
Replace(origin_address, " ", "+") & "&destinations=" & Replace(destination_address, " ", "+") & _
"&mode=" & strmode & "&sensor=false&units=metric"
Set oXH = CreateObject("msxml2.xmlhttp")
With oXH
.Open "get", surl, False
.send
bodytxt = .responseText
End With
bodytxt = Right(bodytxt, Len(bodytxt) - InStr(1, bodytxt, "<text>") - 5)
tim_e = Left(bodytxt, InStr(1, bodytxt, "</text>") - 1)
bodytxt = Right(bodytxt, Len(bodytxt) - InStr(1, bodytxt, "<text>") - 5)
distanc_e = Left(bodytxt, InStr(1, bodytxt, "</text>") - 1)
If datatype = 1 Then
GMap = CDbl(Replace(tim_e, "mins", ""))
ElseIf datatype = 2 Then
GMap = CDbl(Replace(distanc_e, "km", ""))
Else
GMap = "Invalid Data"
End If
Set oXH = Nothing
End Function