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

  • Home
  • SEARCH
  • 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 5987455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:49:03+00:00 2026-05-22T22:49:03+00:00

directionsService.route (request, function (result, status) { alert(status); if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections (result);

  • 0
directionsService.route (request, 
                            function (result, status) 
                            {
                                alert(status);
                                if (status == google.maps.DirectionsStatus.OK)
                                {
                                    directionsDisplay.setDirections (result);

                                    pointsArray = result.routes[0].overview_path;

The problem is that the *result.routes[0].overview_path;* returns an array of type ‘google.maps.LatLng’. i.e. Each element is an “object” of the class ‘google.maps.LatLng’, in that array.

I want to write all those returned latitudes and longitudes on a text file.

How to extract the individual “latitudes and longitudes” values from the object of the class “google.maps.LatLng“

  • 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-22T22:49:03+00:00Added an answer on May 22, 2026 at 10:49 pm

    http://code.google.com/apis/maps/documentation/javascript/reference.html#LatLng

    The above link contains two methods: lat() and lng() which do solve the issue.
    The code for the same is as follows:

    function displayRoute ()
        {
            var start = arrayMarkers [0];
            var end   = arrayMarkers [1];
    
            var request = {
                        origin:start,
                        destination:end,
                        travelMode:google.maps.TravelMode.DRIVING
                        };
    
            directionsService.route (request, function (result, status) 
            {
                if (status == google.maps.DirectionsStatus.OK)
                {
                    directionsDisplay.setDirections (result);
                    pointsArray = result.routes[0].overview_path;
    
                    var i = 0;
                    var j = 0;
    
                    for (j = 0; j < pointsArray.length; j++)
                    {
                        arrayToBeReturned [i] = pointsArray[j].lat ();
                        i++;
                        arrayToBeReturned [i] = pointsArray[j].lng ();
                        i++;
    
                        var point1 = new google.maps.Marker ({
                                                        position:pointsArray [j],
                                                        draggable:false,
                                                        map:map,
                                                        flat:true
                                                        });
                    }
                }
            });
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(function(){ window.onload =function(){ var directionsDisplay; var directionsService = new google.maps.DirectionsService(); directionsDisplay = new google.maps.DirectionsRenderer();
var directionsService = new google.maps.DirectionsService(); var directionsDisplay = new google.maps.DirectionsRenderer(); var startMarker = new
I used to be able to get it like this: directionsService.route(directionsRequest, function(directionsResult, directionsStatus) {
I have strange problem with the Google Maps DirectionsService. It returns me different routes
The GDirections class of Google maps API helped me in displaying the route between
according to google maps i can plan a route that crosses over several waypoints.
I now switched to the v3 API of google maps and offer some route-planning
And that's saying something. This is based on the Google Maps sample for Directions
Loving Google Maps API V3, but having difficulty in getting accurate driving directions and
Hi all I was playing around with the Google Maps Directions API and in

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.