jameschristian
New Member
- Joined
- Aug 25, 2022
- Messages
- 3
- Office Version
- 2016
- Platform
- Windows
Hi all,
I currently use VBA to extract the 'overview polyline' returned from the Google Directions API, and paste it into a spreadsheet. However, I need more accurate polylines. I can get better accuracy if I can stitch together the child node polylines within each step.
How do I convert my code to go from retrieving the 'overview polyline' to retrieving the a string made up of the polylines from each 'step' from each 'leg'? There are variable (>1) legs and variable (>1) steps. I tried making a loop and just made a complete mess.
Please find attached an XML example. The VBA code is below.
I currently use VBA to extract the 'overview polyline' returned from the Google Directions API, and paste it into a spreadsheet. However, I need more accurate polylines. I can get better accuracy if I can stitch together the child node polylines within each step.
How do I convert my code to go from retrieving the 'overview polyline' to retrieving the a string made up of the polylines from each 'step' from each 'leg'? There are variable (>1) legs and variable (>1) steps. I tried making a loop and just made a complete mess.
Please find attached an XML example. The VBA code is below.
VBA Code:
Set objHttp = New MSXML2.XMLHTTP60
With objHttp
.Open "GET", strURL, False
.setRequestHeader "Content-Type", "application/x-www-form-URLEncoded"
.Send
End With
Set objDom = New DOMDocument60
objDom.LoadXML (objHttp.responseText)
Dim strStatus As String
strStatus = objDom.SelectSingleNode("//status").Text
If strStatus = "OK" Then
ReDim aryDest(0, 1)
Dim datanode As MSXML2.IXMLDOMNode
Set datanode = objDom.SelectNodes("//route/overview_polyline")(0)
If datanode.SelectNodes("//status")(0).Text = "OK" Then
strpoly = datanode.SelectNodes("//route/overview_polyline")(0).Text 'This is where I have tried putting in a loop for each leg and each step, but it is a disaster when I do
aryDest(0, 0) = strpoly
Else
aryDest(0, 0) = datanode.SelectNodes("status")(0).Text
End If
Else
ReDim aryDest(0, 0)
aryDest(0, 0) = "NO DATA"
End If