PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 23 → WX - Google Maps Autocomplete (endereco) - GoogleMapsAutocomplete(endereco)
WX - Google Maps Autocomplete (endereco) - GoogleMapsAutocomplete(endereco)
Iniciado por BOLLER, nov., 09 2018 9:42 PM - Sem resposta
Membro registado
2.871 mensagems
Popularité : +89 (91 votes)
Publicado em novembro, 09 2018 - 9:42 PM
// Summary: <specify the procedure action>
// Syntax:
//GoogleMapsAutocomplete (<endereco>)
//
// Parameters:
// endereco: <specify the role of endereco>
// Return Value:
// None
//
// For instance:
// Indicate an example.
//
// xmljson: <specify the role of xmljson>
// XmlJson: <specify the role of XmlJson>
// opcao: <specify the role of opcao>
// geocode: <specify the role of geocode>
Procedure GoogleMapsAutocomplete(endereco)

//https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete
//https://developers.google.com/maps/documentation/javascript/places-autocomplete
//https://developers.google.com/maps/documentation/javascript/reference/places-widget#SearchBoxOptions
//exemplo
//https://maps.googleapis.com/maps/api/place/autocomplete/xml?input=clavio&language=pt-BR&key=AIzaSyDbSVKYPwB1a-_vPbDzAr6LgAfIj4iW2hc

Url is string

Url = "https://maps.googleapis.com/maps/api/place/autocomplete/json?input="

ApiKey is string = "&key=AIzaSyDbSVKYPwB1a-_vPbDzAr6LgAfIj4iW2hc" // api do Boller

Establishment is string = "&types=establishment"
TypeEstablisment is string = "&type=restaurant"
Fields is string = "&fields=opening_hours"
PerimetroMetros is string = "&locationbias=circle:2000"
sLanguage is string = "&language=pt-BR"

//https://developers.google.com/maps/faq#languagesupport
//Language Code Language Language Code Language
//ar Arabic lt Lithuanian
//be Belarusian lv Latvian
//bg Bulgarian mk Macedonian
//bn Bengali ml Malayalam
//ca Catalan mr Marathi
//cs Czech my Burmese
//da Danish nl Dutch
//de German no Norwegian
//el Greek pa Punjabi
//en English pl Polish
//en-Au English (Australian)
//en-GB English (Great Britain)
//pt Portuguese
//pt-BR Portuguese (Brazil)
//pt-PT Portuguese (Portugal)
//es Spanish
//eu Basque ro Romanian
//fa Farsi ru Russian
//fi Finnish sk Slovak
//fil Filipino sl Slovenian
//fr French sq Albanian
//gl Galician sr Serbian
//gu Gujarati sv Swedish
//hi Hindi ta Tamil
//hr Croatian te Telugu
//hu Hungarian th Thai
//id Indonesian tl Tagalog
//it Italian tr Turkish
//iw Hebrew uk Ukrainian
//ja Japanese uz Uzbek
//kk Kazakh vi Vietnamese
//kn Kannada zh-CN Chinese (Simlified)
//ko Korean zh-TW Chinese (Traditional)
//ky Kyrgyz


//Torre Eifel
//https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=48.857832,2.295226&heading=-45&pitch=38&fov=80

IF Length(endereco) > 3 THEN

// if opcao = 1 //All
// Url = Url + endereco + sLanguage + ApiKey //ok
// else if opcao = 2 //Establishment
// Url = Url + endereco + sLanguage + Establishment + ApiKey
// ELSE IF opcao = 3 //Address
// Url = Url + endereco + sLanguage + Establishment + TypeEstablisment + Fields + ApiKey
// ELSE IF opcao = 4 //Geocode
// Url = Url + endereco + sLanguage + geocode + ApiKey
// ELSE IF opcao = 5 //Strict Bounds - viewport atual
// Url = Url + endereco + sLanguage + PerimetroMetros + ApiKey
// else
// Url = Url + endereco + sLanguage + ApiKey
// END

// endereco = URLEncode(endereco)

Url = Url + endereco + sLanguage + ApiKey

HTTPRequest(Url)

bufResultado is Buffer = HTTPGetResult()

IF PositionOccurrence(bufResultado ,"<!DOCTYPE html>",firstRank,FromBeginning) = 0 THEN

vResultado is Variant = JSONToVariant(bufResultado)

LooperDeleteAll(LOOP_Enderecos) //limpa o combo

//leitura do resultado do httpgetresult e alimenta a combo os os resultados
x is int
umavez is int
enderecoLocalizado is string
LOOP (20)
x+= 1
Trace(vResultado.predictions[x].description..Value)
enderecoLocalizado = vResultado.predictions[x].description..Value
IF Length(enderecoLocalizado) > 3 THEN
IF umavez = 0 THEN
umavez = 1
EDT_Busca = enderecoLocalizado
END
LooperAdd(LOOP_Enderecos,enderecoLocalizado)
ELSE
BREAK
END
END

LOOP_Enderecos..Visible = True

LooperDisplay(LOOP_Enderecos,taCurrentFirst)

END

END


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