1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[RESOLVIDO] Latitude e Longitude

Discussão em 'EMS , HCM e Totvs 11' iniciado por paininet, Dezembro 5, 2013.

Status do Tópico:
Não esta aberto para novas mensagens.
  1. paininet

    paininet Membro Participativo

    Boa tarde, galera.

    Alguém já fez algo para atualizar latitude e longitude passando um endereço via webservice ou algo parecido. Preciso pegar essas informações e atualizar dois campos da base para utilizar geolocalização.

    Se alguém tiver alguma ideia agradeço. Obrigado!
  2. paininet

    paininet Membro Participativo

    Consegui, achei um outro post de consulta de CEP, só adaptei para pegar latitude e longitude do Google deu certo.

    Vou postar ai se alguém precisar algum dia só adaptar o código a necessidade. Abraço!

    def var hXDOC as handle no-undo.
    def var hRoot as handle no-undo.
    def var hBuff as handle no-undo.
    def var hField as handle no-undo.
    def var v-endereco as char format "x(50)".

    def temp-table tt-Resposta
    field lat as char format "X(25)"
    field lng as char format "X(25)"
    field formatted_address as char format "X(80)".

    update v-endereco.

    create tt-Resposta.
    assign
    hBuff = buffer tt-Resposta:handle.
    create x-document hXDOC.
    hXDOC:load("file","http://maps.google.com/maps/api/geocode/xml?address=" + replace(v-endereco," ","+") + "&sensor=false", false).
    create x-noderef hRoot.
    hXDoc:get-document-element(hRoot).
    run obtemnode (input hRoot).

    MESSAGE tt-Resposta.lat SKIP
    tt-Resposta.lng SKIP
    tt-Resposta.formatted_address
    VIEW-AS ALERT-BOX INFO BUTTONS OK.

    /* hXDOC:save("file","L:\CEPRetorno.xml"). */

    if valid-handle (hXDoc) then
    delete object hXDoc.
    if valid-handle (hRoot) then
    delete object hRoot.


    procedure obtemnode.
    def input parameter vh as handle.
    def var hc as handle.
    def var loop as int.
    create x-noderef hc.
    do loop = 1 to vh:num-children.
    vh:get-child(hc,loop).
    if hc:subtype = "text"
    then do:
    assign
    hField = hBuff:buffer-field(vh:name)
    no-error.
    if valid-handle(hField) then
    assign
    hField:buffer-value = hc:node-value.
    end.
    run obtemnode (input hc:handle).
    end.
    end.
    hugo_mlcabral1 curtiu isso.
Status do Tópico:
Não esta aberto para novas mensagens.

Compartilhe esta Página