Using a modified version of the quick method from the first post, directions can be returned in either an XML or JSON format:
Code: Select all
InitNetwork()
Debug PeekS(ReceiveHTTPMemory("http://maps.google.com/maps/api/directions/xml?origin=Toronto&destination=Mount+Rushmore"), -1, #PB_UTF8)
Code: Select all
InitNetwork()
Dim output.s(0) ;this will be resized later
Procedure ExplodeStringArray(Array A.s(1), S.s, Delimeter.s)
Protected Count.i, I.i
Count.i = CountString(S.s, Delimeter.s) + 1
;Debug Str(count) + " substrings found"
Dim A.s(Count.i)
For I.i = 1 To Count.i
A.s(I.i - 1) = StringField(S.s, I.i, Delimeter.s)
Next
ProcedureReturn Count.i ;Return count of substrings
EndProcedure
Text.s = PeekS(ReceiveHTTPMemory("http://maps.google.com/maps/api/directions/xml?origin=oslo&destination=gibraltar&&language=en"), -1, #PB_UTF8)
(language=en --> "en" = own language)
ExplodeStringArray(Output(), Text.s, #LF$)
Debug "Travel directions" + ":"
Debug "=================== "
Teller.i = 1
For I.i = 0 To ArraySize(Output())
If FindString(Output(I.i), "<html_instructions>", 1) > 0
Output(I.i) = RemoveString(Output(I.i), "<html_instructions>")
Output(I.i) = RemoveString(Output(I.i), "</html_instructions>")
Output(I.i) = RemoveString(Output(I.i), " ")
Output(I.i) = RemoveString(Output(I.i), ";b>")
Output(I.i) = RemoveString(Output(I.i), "<")
Output(I.i) = RemoveString(Output(I.i), ";/b>")
Output(I.i) = RemoveString(Output(I.i), ";/div>")
Output(I.i) = RemoveString(Output(I.i), ";div style="font size:0.9em">")
Output(I.i) = RemoveString(Output(I.i), ";div style="font-size:0.9em">")
Debug RSet(Str(Teller.i), 3, "0") + " - " + Output(I.i)
Teller.i + 1
EndIf
Next I.i
Debug ""
Debug "End travel directions" + ":"
Debug "========================="