Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
How to get geocoder result from async callback funtion

First of all, I should say that I dont have a lot of experience working with TS/JS.

I am working on an angular project that requires me to find lat, long from a given address and use that value in a different component. I'm using the google geocoder service and my aim is to get lat, long from the results and store it in a global variable.

This is my service call:

var res = this.geocoder.geocode({address: this.address }, getGeoResults);

And this is the callback:

GeoLoc: any;

getGeoResults( results, status) {
    if(status == google.maps.Geocoderstatus.OK) {
     this.geoLoc = results
    }
}

But the issue is that neither can I get the results from the service into 'res' variable as it returns a ZoneAwarePromise nor can I use any other global variable(GeoLoc) to store the results inside the callback function(error: Cannot set property of undefined) as it is an async function.

Please suggest any method either by getting results in res variable or by storing it in another global variable in the callback function. Or any other method where we can get data from a async callback.

Thank you!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!