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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:48:49+00:00 2026-06-10T12:48:49+00:00

The google maps v3 directionsService returns lat/long points that are sometimes longer than I

  • 0

The google maps v3 directionsService returns lat/long points that are sometimes longer than I want. Here is a call I might make:

var request = {
    origin: start_position, 
    destination: end_position,
    travelMode: google.maps.DirectionsTravelMode.DRIVING
};

directionsService.route(request, function(response, status) {
    if (status === google.maps.DirectionsStatus.OK) {
        // do something with response, e.g. set the overview_path to a polyline;
    }
});

The resulting response might return the following values for a point:

response.routes[0].legs[0].start_location.Xa = 35.077000000000005    
response.routes[0].legs[0].start_location.Ya = -85.08854000000001

I really want to lessen the precision. For example I would prefer values to a precision of five decimal places like this:

Xa = 35.07700    
Ya = -85.08854

Is there an easy way to accomplish this? I have looked through the documentation and I don’t see any mention of a way to set this.

Thanks for any insight or help you might offer!

  • 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-10T12:48:51+00:00Added an answer on June 10, 2026 at 12:48 pm

    First of all you shouldn’t use .Xa and .Ya because those are minified names that can change with the next release of the API. Instead you should use the documented methods lat() and lng(). so:

    response.routes[0].legs[0].start_location.lat()= 35.077000000000005    
    response.routes[0].legs[0].start_location.lng() = -85.08854000000001
    

    and if you want to round the decimals then you’d use the standard javascript method .toFixed(), that is:

    var lat = response.routes[0].legs[0].start_location.lat().toFixed(5);// 35.07700    
    var lon = response.routes[0].legs[0].start_location.lng().toFixed(5);// -85.08854
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Google Maps APIs require 3 parameters to start with: lat, long and zoom level.
Google Maps gives me the Lat and Long of a location in decimal notation
I have strange problem with the Google Maps DirectionsService. It returns me different routes
I'm working with google maps api and I want the label of a marker
var directionsService = new google.maps.DirectionsService(); var directionsDisplay = new google.maps.DirectionsRenderer(); var startMarker = new
And that's saying something. This is based on the Google Maps sample for Directions
I am using the Directions Service of Google Maps V3 API, and I want
directionsService.route (request, function (result, status) { alert(status); if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections (result);
I have had some problems with the directionsService object of google maps API v3.
I have a Google Maps project, and I want to do an array 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.