I wanted to call this function within my anonymous function, how can I do that?

Asked

Viewed 96 times

1

retonaEndereco(myLatlng,adress => {

    let  getDistance = function (origin,destination) {
         let distance = geolib.getDistance(origin,destination);
         return geolib.convertUnit('km',distance);
      }


     var getAllDistances = function ()
     {
      // var dados = dadosEndereco;

      let distanciaCalc =  getDistance(
                    {latitude:-23.624467,
                    longitude:-46.731728},

                    {latitude:adress.geometry.location.lat(),
                    longitude:adress.geometry.location.lng()}
          )


           return  parseFloat(distanciaCalc).toFixed(2);
     }
     var km = getAllDistances;

     var dadosEndereco = {
             "Rua/Avenida": adress.address_components[0].long_name,
             "Bairro" : adress.address_components[1].long_name,
             "Cidade" : adress.address_components[3].long_name,
             "UF" : adress.address_components[4].short_name,
             "km" : km

     };
    this.returnDados(dadosEndereco);
    });
});

}

private returnDados (dados){
    this.nav.push(NovoPedidoPage,dados)
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.