Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8055885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:32:15+00:00 2026-06-05T08:32:15+00:00

I have the code: country: (origin) -> @geocoder = new google.maps.Geocoder @geocoder.geocode( ‘latLng’: origin,

  • 0

I have the code:

  country: (origin) ->
    @geocoder = new google.maps.Geocoder
    @geocoder.geocode(
        'latLng': origin,
        (results, status) => 
            if status is google.maps.GeocoderStatus.OK
              return results[6]
            else alert("Geocode was not successful for the following reason: " + status);
    )

I am calling it in backbone.js as:

test = @country(origin)
console.log(test)

As a test I am using the console.log. However I am getting an:

undefined

response, as the country function is not returning anything. I know that results[6] has data in it, as I can do a conolse.log there and it returns.

How can I make the country function return result[6] when called?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:32:16+00:00Added an answer on June 5, 2026 at 8:32 am

    I don’t know that API, per se, but it looks like it’s asynchronous, which means you cannot get the function to return the value. Instead, you’ll have to pass in a continuation function that deals with the result when it becomes available.

    country: (origin, handleResult) ->
        @geocoder = new google.maps.Geocoder
        @geocoder.geocode(
            'latLng': origin,
            (results, status) => 
                if status is google.maps.GeocoderStatus.OK
                  handleResult(results[6])
                else alert("Geocode was not successful for the following reason: " + status);
        )
    

    To use this, simply craft a function that knows what to do with the result and pass it to the country function:

    obj.country origin, (result) ->
        alert 'Got #{result} from Google'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that I only have a country code (en, de, fr) and I need
I have an entity object Country with country name and country code. It is
I have a string which I need to verify if it's a Country code.
basically i have (state, state code) pairs, that are subsets of country [USA] ->
I have a code like this that extract the country code saved in the
I have the following code for handling phone numbers such as country code for
in my database i have phone numbers with country code , which look somthing
I have this code : private void insertValus() { ContentValues initialValues = new ContentValues();
I have this code for requesting google to correct the typed in address, and
I have next code getEntityManager().persist(country.getCity().getClinic().getPatient()); and see next sql in log Hibernate: select next

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.