0

I have a function in excel to extract travel distance using Google Maps API that looks like this: Function TRAVELDISTANCE(origin, destination, apikey)

Dim strUrl As String
strUrl = "https://maps.googleapis.com/maps/api/directions/json?origin=" & origin & "&destination=" & destination & "&key=" & apikey
 
Set httpReq = CreateObject("MSXML2.XMLHTTP")
With httpReq
     .Open "GET", strUrl, False
     .Send
End With
 
Dim response As String
response = httpReq.ResponseText
 
Dim parsed As Dictionary
Set parsed = JsonConverter.ParseJson(response)
Dim KM As Long
 
Dim leg As Dictionary
 
 
For Each leg In parsed("routes")(1)("legs")
    meters = meters + leg("distance")("value")
Next leg
 

TRAVELDISTANCE = meters

End Function

Does anyone know how I can edit this to give me the value "Ferry" if the route includes a ferry?

1 Answers1

0

Maybe this.

https://www.google.com/maps/dir/50.8971936,-1.397307/50.8653945,-1.3991824/@50.8705321,-1.4018442,16z/am=t/data=!4m6!4m5!3e2!6m3!1i0!2i0!3i7

F2 to see the code behind the page.

enter image description here

ASH
  • 20,759
  • 19
  • 87
  • 200