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 9278533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:23:59+00:00 2026-06-18T17:23:59+00:00

So, I am using google’s reverse geocoder, so what I originally do is enter

  • 0

So, I am using google’s reverse geocoder, so what I originally do is enter an address such as, tokyo, then I get that latlng take the latlng and place it back into the geocoder to receive the proper name of the location but instead it just returns undefined. My code is:

var geocoder = new google.maps.Geocoder();
var place = document.getElementById("location").value;
var name;
var place_latlng;
geocoder.geocode({'address' : place}, function(results, status){
  if (status == google.maps.GeocoderStatus.OK){
    place_latlng = results[0].geometry.location;
    addMarker(place_latlng);
  }
});
geocoder.geocode({'latLng' : place_latlng},function(results, status){
  if (status == google.maps.GeocoderStatus.OK){
    name = results[0].formatted_address;
  }
});

name ends up being undefined every time, is there a way I can fix this?

  • 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-18T17:24:01+00:00Added an answer on June 18, 2026 at 5:24 pm

    The Geocoder is asynchronous, you need to use the data returned by the Geocoder inside its callback function (not tested):

    geocoder.geocode({'address' : place}, function(results, status){
      if (status == google.maps.GeocoderStatus.OK){
        place_latlng = results[0].geometry.location;
        addMarker(place_latlng);
        geocoder.geocode({'latLng' : place_latlng},function(results, status){
          if (status == google.maps.GeocoderStatus.OK){
            name = results[0].formatted_address;
            alert("name = "+name);
          } else { alert("reverse geocode of "+place_latlng+ " failed ("+status+")"); }
        });
      } else { alert("geocode of "+place+" failed ("+status+")"); }
    });
    

    Example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have been using google AJAX API loader (to get the location of a
Without using Google Checkout, I would like to provide a link that allows a
iam using google map in my php script to display the address of a
Using Google Apps Script, I created a calendar that has a complex recurring event.
Im using Google BigQuery and have a questions of the POSITION(field) function that it
Scope: Using Google Test and OpenCV. I'd like to test that my Vec3f equals
On using Google I found that they are using onclick events in anchor tags.
When using Google App Engine with Django-nonrel, is there any way to take advantage
Using Google Checkout, I'm able to estimate tax based on the zip code that's
Im using google chrome and i want that profile text with the background to

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.