FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV Mobile 2024
→
Endereco das Coordenadas Latitude e Longitude
Endereco das Coordenadas Latitude e Longitude
Débuté par adrianoboller, 18 nov. 2014 13:46 - Aucune réponse
Connectez-vous…
adrianoboller
#1
Membre enregistré
3 655 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 13:46
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
//pLatitude= "-25.431637"
//plongitude ="-49.203203"
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
)
// SEM ACENTO
RetJson
=
WS_Android_IOS_HTTPGetResult
(
)
//HTTPGetResult(httpResult)
IF
Length
(
RetJson
) =
0
THEN
ok
=
False
ELSE
IF
DebugSN
=
"S"
Info
(
Url
,
RetJson
)
END
//
/// teste
//
TagEndac is string
//
io is int = PositionOccurrence(RetJson, TagEndac, firstRank, IgnoreCase )// + Length(TagEndac)
//
//
//
TagEndac = Middle(retjson,PositionOccurrence(RetJson,"""address_components"" :", firstRank, IgnoreCase ),Length(RetJson))
//
blocoJson is string = Middle( tagEndac,1,PositionOccurrence(TagEndac,"],", firstRank, IgnoreCase ))
//
//<Result> = ExtractString(<Initial String> , <Rank> [, <Separator> [, <Browse Direction>]])
//
// if (blocoJson<> "") THEN
//
Endereco = ExtractString(blocoJson,firstRank,"""types"" : [ ""street_number"" ]",FromEnd)
//
END
//
//
//Pega endereço (entre duas aspas)
//
IF io> 0 THEN
//
Endereco = ExtractString(RetJson[[io TO]],4,"""")
//
GloEnderecoOK = True
//
//
END
//
//teste
//
TagEnd is
string
=
""
"formatted_address"
" :"
i is
int
=
PositionOccurrence
(
RetJson
,
TagEnd
,
firstRank
,
IgnoreCase
) +
Length
(
TagEnd
)
Endereco
=
""
//Pega endereço (entre duas aspas)
IF
i
>
0
THEN
Endereco
=
ExtractString
(
RetJson
[
[
i TO
]
]
,
2
,
""
""
)
GloEnderecoOK
=
True
END
IF
Endereco
=
""
OR
RetJson
=
"ERRO"
THEN
// busca por XML
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
(
)
// HTTPGetResult(httpResult)
IF
Length
(
RetXml
) =
0
THEN
ok
=
False
ELSE
IF
DebugSN
=
"S"
Info
(
"Xml:"
,
RetXml
)
END
//<formatted_address>Rua Professora Antonia Reginato Vianna, 442 - Capão da Imbuia, Cajuru, Curitiba - PR, 82810-300, Brasil</formatted_address>
IF
PositionOccurrence
(
RetXml
,
"<formatted_address>"
,
firstRank
) >
0
THEN
//Endereço
n
PosicaoInicial is
int
=
PositionOccurrence
(
RetXml
,
"<formatted_address>"
,
firstRank
) +
Length
(
"<formatted_address>"
)
n
PosicaoFinal is
int
=
PositionOccurrence
(
RetXml
,
"</formatted_address>"
,
firstRank
) +
Length
(
"</formatted_address>"
)
n
PosicaoFinal
=
n
PosicaoFinal
-
n
PosicaoInicial
Endereco
=
Middle
(
RetXml
,
n
PosicaoInicial
,
n
PosicaoFinal
)
GloEnderecoOK
=
True
END
END
END
END
END
END
IF
ok
=
False
THEN
Popup
(
GloMsgSemInternet
,
"L"
)
END
Endereco
=
WS_RemoveAcentos
(
Endereco
)
END
RESULT
(
Endereco
)
>
Signaler
0
0
→ Revenir à WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte