我相信Google API可以让您获得给定地址的坐标。然而,我发现的大多数(或者应该说全部)例子都不适用于vb。通常这是一些JavaScript例子,只是让我感到困惑。从地址获取GPS坐标的代码(VB6/VBA/VBScript)
这是我使用地理编码服务的一些代码。这很好。这只是我想直接查询Google地图。
Public Function fgGetLatAndLongUsingAddress(sAddress As String) As String
'This function works best with a complete address including the zip code
Dim sResponseText As String, sReturn As String
sReturn = "none"
Dim objHttp As Object, sQuery As String
sQuery = "http://rpc.geocoder.us/service/csv?address=" & Replace(sAddress, " ", "+")
Set objHttp = CreateObject("Msxml2.ServerXMLHTTP")
objHttp.Open "GET", sQuery, False
objHttp.send
sResponseText = objHttp.ResponseText
gsLastLatLongResponseText = sResponseText
Set objHttp = Nothing
If Len(sResponseText) > 0 Then
If InStr(sResponseText, "Bad Request") > 0 Then
'Do Nothing
ElseIf InStr(sResponseText, "couldn't find this address") > 0 Then
'Do Nothing
Else
If InStr(sResponseText, vbCrLf) > 0 Then
'We got more than one result
End If
If InStr(sResponseText, ",") > 0 Then
Dim aryInfo() As String
aryInfo = Split(sResponseText, ",")
sReturn = aryInfo(0) & "," & aryInfo(1)
End If
End If
End If
fgGetLatAndLongUsingAddress = sReturn
End Function
+1表示技术的正确性,-1表示可能违反Google的地理编码服务[条款和条件](https://developers.google.com/maps/documentation/geocoding/)。 Quote:*地理编码API只能与Google地图一起使用;不允许在[Google]地图上显示地理编码结果。* – MarkJ 2013-08-12 14:49:25