Digamos que queira saber a Latitude e a Longitude de qualquer endereço. Como faria? Poderá usar a solução abaixo:
Function Lat_Lon (a_t As String, c_t As String, s_t As String, co_t As String, z_t As String)
Dim sURL As String
Dim BodyTxt As String
Dim apan As String, la_t As String, lo_g As String
Dim oXH As Object
' Criando a URL
Let sURL = "http://maps.googleapis.com/maps/api/geocode/xml?address="""
Let sURL = sURL & Replace(a_t, " ", "+") & ",+" & _
Replace(c_t, " ", "+") & ",+" & _
Replace(s_t, " ", "+") & ",+" & _
Replace(co_t, " ", "+") & ",+" & ",+" & _
Replace(z_t, " ", "+") & ",+" & "&sensor=false"""
' Informando o URL para o browse
Set oXH = CreateObject("msxml2.xmlhttp")
With oXH
.Open "get", sURL, False
.Send
Let BodyTxt = .RESPONSETEXT
End With
Let apan = Application.WorksheetFunction.Trim(BodyTxt)
'Latitude
Let apan = Right(apan, Len(apan) - InStr(1, apan, "<lat>") - 4)
Let la_t = Left(apan, InStr(1, apan, "</lat>") - 1)
'Longitude
Let apan = Right(apan, Len(apan) - InStr(1, apan, "<lng>") - 4)
Let lo_g = Left(apan, InStr(1, apan, "</lng>") - 1)
Let lat_lon = "Lat:" & la_t & " Lng:" & lo_g
End Function
#A&A #Google #GoogleMap #API #GoogleAPI #VBA #Latitude #Longitude #PIECEOFCAKE #POC
Consulte-nos
⬛◼◾▪ CONTATO ▪◾◼⬛
Nenhum comentário:
Postar um comentário