dumbwithdata
New Member
- Joined
- May 26, 2017
- Messages
- 3
I have been muddling together calls to Google Maps API with an Excel sheet and after lots of testing and borrowing samples from other peoples projects (that I do not quite understand) I have the whole package working perfectly. Basically the workbook has multiple sheets and each of these sheets has one destination and about 30 origins. The call goes out to Google for all 30 of these and the Excel looks the duration value for each. Well I have altered the call to get the 'duration_in_traffic' value as opposed to the duration value. However, I cannot get these results to appear in my sheet. If I change this to distance rather than duration_in_traffic it will return the value fine. I am lost as to what the issue is. I have tried to troubleshoot based on my limited knowledge and:
The only thing I can think of, which is related to that last point, is that the 'duration_in_traffic' value is only provided one in a call whereas the distance and duration values are provided multiple times for each step and then a total one which is the one we grab, but not sure about this. This is what the relevant portion of the current call looks like:
Thank you for any help that you can provide and I am hoping that the issue is really only because I am doing cut and paste code with no real clue. Thank you.
- If I make the call straight in Chrome, it comes back with all of the correct data so I know that this element is fine.
- I changed to distance item so I know that it is not some strange naming or the like that needs to be changed in the VBA.
- I tried multiple iterations with the 'duration_in_traffic' to see if some standard I was missing.
- I reviewed the XML results that come back when you call in Chrome and I cannot see any structural difference that would make the call for distance and duration the same but duration_in_traffic different.
The only thing I can think of, which is related to that last point, is that the 'duration_in_traffic' value is only provided one in a call whereas the distance and duration values are provided multiple times for each step and then a total one which is the one we grab, but not sure about this. This is what the relevant portion of the current call looks like:
Code:
Set myDomDoc = New DOMDocument60
myDomDoc.LoadXML myRequest.responseText
' If statusNode is "OK" then get the values to return
Set statusNode = myDomDoc.SelectSingleNode("//status")
If statusNode.Text = "OK" Then
If NoCache Then: Call CreateFile(CachedFile, myRequest.responseText) ' Cache API response if required
' Get the duration
Set durationNode = myDomDoc.SelectSingleNode("//leg/duration/value")
If Not durationNode Is Nothing Then G_DURATION = val(durationNode.Text) / 60 ' Now works with comma as decimal separator
End If
Thank you for any help that you can provide and I am hoping that the issue is really only because I am doing cut and paste code with no real clue. Thank you.