PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → WX - HTTPCreateForm
WX - HTTPCreateForm
Débuté par BOLLER, 22 juil. 2017 03:06 - Aucune réponse
Membre enregistré
3 655 messages
Popularité : +175 (223 votes)
Posté le 22 juillet 2017 - 03:06
Procedure WS_RotasGoogleMapsFunc(enderecoOrigem is string) : string

IF IniOSMode() THEN
Multitask(-3)
ELSE
IF InAndroidMode() THEN
Multitask(3)
END
END

Resultado is string

IF enderecoOrigem = ""
RESULT(Null)
END

enderecoOrigem = Replace(enderecoOrigem,CR,"+")

//Limpa variaveis
gsFuncionarioEnderecoLongo=""
gsDestinoEnderecoLongo=""
gsTempoDestino=""
gsDistanciaDestino=""
gsHtmlInstructions=""
gsPoligonalGoogle=""

grDistanciaCarro=0
grTempoCarro=0
grNortelatitude=0
grNorteLongitute=0
grSullatitude=0
grSulLongitute=0

HTTPTimeOut(5000)

HTTPCreateForm("GoogleMaps")
HTTPAddParameter("GoogleMaps","origin", enderecoOrigem)
HTTPAddParameter("GoogleMaps","destination", enderecoOrigem)
HTTPAddParameter("GoogleMaps","language", "pt-BR")
HTTPAddParameter("GoogleMaps","region", "br")
HTTPAddParameter("GoogleMaps","units", "metric")
HTTPAddParameter("GoogleMaps","key","AIzaSyDbSVKYPwB1a-_vPbDzAr6LgAfIj4iW2hc") //CHAVE GOOGLE

cMyRequest is a httpRequest
cMyRequest..URL = "https://maps.googleapis.com/maps/api/directions/xml"
cMyRequest..Method = httpGet

cMyResponse is a httpResponse = HTTPSendForm("GoogleMaps", cMyRequest)

IF cMyResponse..StatusCode <> 200 THEN // Se não funcionou
RESULT(Null)
END

xmlGoogle is a xmlDocument = XMLOpen(cMyResponse..Content, fromString)
IF NOT xmlGoogle.DirectionsResponse.status..Text ~= "OK" THEN
RESULT(Null)
END

//Lendo nos unicos
Debug("WS_RotasGoogleMaps",cMyResponse..Content)

gsFuncionarioEnderecoLongo = xmlGoogle.DirectionsResponse.route.leg.start_address
grLatitudeFuncionarioThread = xmlGoogle.DirectionsResponse.route.leg.start_location.lat
grLongitudeFucionarioThread = xmlGoogle.DirectionsResponse.route.leg.start_location.lng

//Loop nos nós do xml

Contador is int = 1
FOR EACH legNode OF xmlGoogle.DirectionsResponse.route.leg
IF legNode..Name = "step" THEN
HTML is string = legNode.html_instructions
Distancia is int = legNode.distance.value
Resultado += Contador + ". " + HTML + " [" + Distancia + "]" + CR
Contador++
END
END
// </Xml>RESULT(Resultado)


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/