**************************************
FUNCTION calcwebdist (cAddress1, cAddress2,cNom,cJour)
LOCAL cUrl, oHTTP, oXMLDOM, oOrigine
LOCAL oDestination,oState,ocDuree,ovDuree ,ocDistance, ovDistance
cUrl="http://maps.googleapis.com/maps/api/distancematrix/xml?origins=" +cAddress1+ "&destinations=" +cAddress2 + "&mode=driving&language=fr-FR&sensor=false"
oHTTP = CreateObject("MSXML2.XMLHTTP")
oHTTP.Open("GET", cURL, .f.)
oHTTP.Send
oXMLDOM = oHTTP.responseXML
oOrigine = oXMLDOM.selectNodes("//origin_address")
IF oOrigine.length != 1 then
     RETURN ("")
ELSE
    ciao = oOrigine.item(0).text
ENDIF
IF NOT USED("distance")
    CREATE CURSOR distance (nom c(50),  jour date, depart c(70), arrivee c(70), duree c(15), durees N(10), distance c(15), distancem n(10),  etat L)
endif
oDestination = oXMLDOM.selectNodes("//destination_address")
oState = oXMLDOM.selectNodes("//status")
ocDuree = oXMLDOM.selectNodes("//duration / text")
ovDuree = oXMLDOM.selectNodes("//duration / value")
ocDistance = oXMLDOM.selectNodes("//distance / text")
ovDistance = oXMLDOM.selectNodes("//distance / value")
FOR i= 0 TO odestination.length -1
    IF ostate.item(i).text = 'OK' THEN
        INSERT INTO distance(nom, jour,depart, arrivee, duree, durees, distance, distancem, etat) VALUES ;
        (cNom, CTOD(cJour),ciao,oDestination.item(i).text ,ocDuree.item(i).text, VAL(ovDuree.item(i).text), ocDistance.item(i).text, VAL(ovDistance.item(i).text),.T.)
    ELSE
        **INSERT INTO distance(depart, arrivee, duree, distance,etat) VALUES ;
        (ciao,'NON GEOCODEE' ,',',.F.)
    ENDIF
NEXT