|
Endereco das Coordenadas Latitude e Longitude |
Started by adrianoboller, Nov., 18 2014 1:46 PM - No answer |
| |
| | | |
|
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on November, 18 2014 - 1:46 PM |
Procedure WS_CEP_EnderecoDasCoordenadas(LOCAL pLatitude is string, LOCAL pLongitude is string, LOCAL DebugSN)
IF GloDebugSN = "S" THEN Info("WS_CEP_EnderecoDasCoordenadas") DebugSN = "S" END
NextTitle("Atenção")
ok is boolean = False GloEnderecoOK = False
Endereco, RetJson is string = "" IF pLatitude <> 0 AND pLongitude <> 0 AND pLatitude <> Null AND pLongitude <> Null THEN
Url is string = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + pLatitude + "," + pLongitude + "&sensor=true"
IF DebugSN = "S" Info("01",Url) END
HTTPTimeOut(GloHTTPTimeOut)
ok = HTTPRequest(Url)
IF ok = True THEN
ChangeCharset(charsetOccidental)
RetJson = WS_Android_IOS_HTTPGetResult() IF Length(RetJson) = 0 THEN
ok= False ELSE
IF DebugSN = "S" Info(Url,RetJson) END
TagEnd is string = """formatted_address"" :" i is int = PositionOccurrence(RetJson, TagEnd, firstRank, IgnoreCase ) + Length(TagEnd) Endereco =""
IF i> 0 THEN Endereco = ExtractString(RetJson[[i TO]],2,"""") GloEnderecoOK = True
END
IF Endereco = "" OR RetJson = "ERRO" THEN
GloEnderecoOK = False Url = "http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + pLatitude + "," + pLongitude + "&sensor=true"
IF DebugSN = "S" Info("02",Url) END
HTTPTimeOut(GloHTTPTimeOut)
ok = HTTPRequest(Url) IF ok = True THEN
RetXml is string = WS_Android_IOS_HTTPGetResult()
IF Length(RetXml) = 0 THEN
ok= False ELSE
IF DebugSN = "S" Info("Xml:",RetXml) END
IF PositionOccurrence(RetXml,"<formatted_address>",firstRank) > 0 THEN
nPosicaoInicial is int = PositionOccurrence(RetXml,"<formatted_address>",firstRank) + Length("<formatted_address>") nPosicaoFinal is int = PositionOccurrence(RetXml,"</formatted_address>",firstRank) + Length("</formatted_address>") nPosicaoFinal = nPosicaoFinal - nPosicaoInicial Endereco = Middle(RetXml,nPosicaoInicial,nPosicaoFinal) GloEnderecoOK = True
END END END END END END
IF ok = False THEN Popup(GloMsgSemInternet,"L") END
Endereco = WS_RemoveAcentos(Endereco)
END
RESULT (Endereco) |
| |
| |
| | | |
|
| | | | |
| | |
|