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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:26:15+00:00 2026-06-01T10:26:15+00:00

I am using javascript, google direction service I have multiple source points on the

  • 0

I am using javascript, google direction service
I have multiple source points on the map and one destination point. I need to find the closest source point to the destination point. As direction service works asynchronously I need to map points with their lat/lang. However the problem is that, the response format sent by direction service changes.

    function calcRoute(start, end) {
    var request = {
        origin:start,
        destination:end,
        travelMode:google.maps.DirectionsTravelMode.DRIVING
    };

    directionsService.route(request, 
        function (response, status) {
            distanceCount++;
            if (status == google.maps.DirectionsStatus.OK) {                    
                var dist = computeTotalDistance(response);
                console.log(dist);
                if (dist < minDistance) {
                    minDistance = dist;
                    minDistanceIndex = locationsMap[response.ug.origin.Ua+""+response.ug.origin.Va];
                }
                if (distanceCount == vl.length) {
                    drawWay(vl[minDistanceIndex], fsl);
                }
            }
        }
    );
}

The problem occurs on the line

minDistanceIndex = locationsMap[response.ug.origin.Ua+""+response.ug.origin.Va];

response.ug.origin.Va and response.ug.origin.Ua comes from google direction service, however it sometimes changes to response.ug.origin.Xa and response.ug.origin.Ya.

Do you have any ideas why it changes from time to time? or any ideas how to deal with that problem?

  • 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-01T10:26:17+00:00Added an answer on June 1, 2026 at 10:26 am

    You don’t have to access those internal properties, they are not a part of the API so they may change.

    Use only the properties/methods defined inside the specification, all data provided by the response are accessible through them,

    example:

    response.routes[0].legs[0].start_location
    //returns latLng of the origin
    

    Apart from that:

    Your description sounds as if you better should use a DistanceMatrixRequest

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

Sidebar

Related Questions

I have a scenario where I am using Google Map JavaScript API to process
I want to call a google service using javascript with a keyword and a
I am dynamically changing the cursor type on a Google Map using the Javascript
I have 4 days of experience with Google Maps Javascript API and i find
using javascript google-maps api I currently have it setup to remove a maker I
I need to write to HKEY_CURRENTUSER using javascript. It should work on Google chrome
I have built an Plagiarism Detection application, using Google API and JavaScript which is
I have made the same Google map web page with more than two destination
I plan to include google map using javascript api to show search results for
When using Google Chrome, I want to debug some JavaScript code. How can I

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.