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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:54:28+00:00 2026-06-16T01:54:28+00:00

how can i parse the response from google direction services ? I am calling

  • 0

how can i parse the response from google direction services ?
I am calling javascript code from my iOS WebView, i want to return some value from java script to iOS. I can see the response when i use alert function to display, but it not returning value. I think this is may be the function is callback function. So what should i do ? please tell me the solution

This is my code:

    var value = function() {

var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
   // var response=new google.maps.DirectionsResult;

var map = new google.maps.Map(document.getElementById('map'), {
                              zoom:7,
                              mapTypeId: google.maps.MapTypeId.ROADMAP
                              });

directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('panel'));

var request = {
    origin: 'Chicago',
    destination: 'New York',
    travelMode: google.maps.TravelMode.TRANSIT
};
var temp;
directionsService.route(request,
                        function(response, status)
                        {
                           if (status == google.maps.DirectionsStatus.OK)
                            {
                           t=response.routes[0].copyrights;
                           temp=t;
                           alert(t);
                            directionsDisplay.setDirections(response);
                                  return t;

                            }
                        } );

     return temp;

};
  • 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-16T01:54:30+00:00Added an answer on June 16, 2026 at 1:54 am

    Instead of using the returnValue of value() as a variable inside another function you must call the other function inside the callback of directionsService.route() and pass t as argument to the other function.

    Requesting the directionsService is an asynchronous process, it isn’t finished yet when value() returns temp, that’s why temp still will be undefined.

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

Sidebar

Related Questions

I want to get some response from WebServer. The returning data looks like this:
This is the json response from my server . How can i parse it
Im trying to parse a response from google weather api, but i get this
Can not parse json using this var res = eval('(' + response + ')');
How i can parse and extract the parameters from an SQL Query using delphi?
I am getting a response back from a Google Search Appliance suggest service in
I have some python code for Google App Engine that responds with the string
I am trying to download some JSON from the google book API. The URL
For a specific requirement in my project, I want to retrieve JSON response from
How to parse XML response coming from the server in C. Do we have

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.