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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:38:04+00:00 2026-05-27T03:38:04+00:00

I am developing a Pure Java program that takes an Address in the form

  • 0

I am developing a Pure Java program that takes an Address in the form of text and the passes it to Google Map API for further breaking in Country,State and Zip.

But I got stuck somewhere where my Java Program is throwing an exception resulting in awkward results.

Now I decided to use the java integrating it with Rhino.
This is because I successfully developed a Web Page that takes a string and parses it in Country,State and Zip.
So now my thinking is that I will integrate this JavaScript file in my Java file using Rhino.

           function showLocation(address) {
                var geocoder;
                if(!geocoder){
                    alert("GC is initialised");
                    geocoder = new GClientGeocoder();
                }

                geocoder.getLocations(address , function(response)
                     {
                        if (!response || response.Status.code != 200) {alert("Sorry, unable to locate that address");}
                        else {
                          place = response.Placemark[0];
                        }
                     }//END OF CALLBACK METHOD
                );//END OF GETLOCATIONS
           }//end of showLocation

Now my question is that how can I return the object of place when I call showLocations()

  • 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-05-27T03:38:05+00:00Added an answer on May 27, 2026 at 3:38 am

    You can’t! Since getLocations is asynchronous, showLocation has already finished executing before response is available.

    You need to accept a callback to showLocation. There are some other problems which I will fix below.

    function showLocation(address, callback) {
        var geocoder = new GClientGeocoder(); // no need for !geocoder test--it will always be undefined!
    
        geocoder.getLocations(address , function(response) {
            if (!response || response.Status.code != 200) {
                alert("Sorry, unable to locate that address");
            } else {
                // you forgot the "var" before "place"--you were making a global variable "place"
                var place = response.Placemark[0];
                if (callback) callback(place);
            }
        });
    }
    

    Then you make the user supply a callback like so:

    function placeCallback(place) {
        // do something with place object here
    }
    showLocation('my address', placeCallback);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a custom autocomplete control in pure WinApi, and the problem that I've
I'm developing a text analysis desktop application, that intensively queries local database (MSSQLCE 3.5).
I'm developing a webapp with Java backend and Flash (pure ActionScript) frontend using BlazeDS.
I have a Pure AS3 mobile project that I'm developing in Flex 4.5, and
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
I'm developing a web game in pure Python, and want some simple scripting available
We're in the middle of developing a e-commerce application that will be used by
We are considering using PhoneGap for an iPad application that we are developing. We
Background I am developing a highly modular application in pure Action Script 3 (we
Possible Duplicate: how to extract plain text from ms word document file in pure

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.