Retrieve DirectionsResult data from a Google Maps URL

Currently, I am developing an updated tool that can transform Google Maps directions into GPX files. The initial version of this tool is performing quite well: it utilizes the Google Maps Javascript API (v3) to showcase a map on the website, allowing users to plan their route using familiar methods similar to those on the main Google Maps page.

An important feature of this site (and the functionality in previous versions prior to Google making changes to their undocumented &output=kml interface!) involves users mapping out their routes on the main Google Maps platform and saving the link for future reference. By pasting this link onto the site, the tool would then convert the planned route into a GPX file.

I am curious if there is a method to extract a DirectionsResult from a Google Maps URL or the main Google Maps page (potentially achieved by submitting the URL to the Google Maps API for analysis or utilizing a bookmarklet on the webpage itself).

Answer №1

The DirectionsResult object is not directly accessible through the link provided on maps.google.com. However, the endpoints and any waypoints specified should yield the same result when given the same input.


Update

Below is a breakdown of the URL from the supplied link, with 24 total waypoints (including 2 end points). The 'geocode' parameter remains somewhat mysterious.

https://maps.google.co.uk/maps?
saddr=Unknown+road  //1
daddr=51.59782,-2.08838 //2
+to:51.74885,-1.94076   //3
+to:51.89255,-1.87129   //4
+to:51.82571,-1.79752   //5
+to:B4020   //6
+to:51.8183,-1.41985    //7
+to:51.72228,-1.43255   //8
+to:51.6239798,-1.3071767   //9
+to:B4001   //10
+to:51.34501,-1.34062   //11
+to:51.35822,-1.12071   //12
+to:51.31526,-1.02412   //13
+to:51.08784,-1.62069   //14
+to:51.29048,-1.73004   //15
+to:51.21761,-1.98589   //16
+to:51.397,-2.13542 //17
+to:Gloucester+Rd%2FA46 //18
+to:51.69001,-2.22161   //19
+to:51.81753,-2.07376   //20
+to:Southam+Ln  //21
+to:52.06075,-1.95706   //22
+to:52.1244,-1.64775    //23
+to:Unknown+road    //24

hl=en
sll=51.421477,-1.238708
sspn=0.804988,2.425232
geocode=Fe3uEwMd_znk_w%3BFfxREwMdRCLg_ylHpOCHwW1xSDHRnVfMI4sNEw%3BFfKfFQMd6GLi_ymv2fIl5RVxSDFAVssIXhupMA%3BFUbRFwMdRnLj_yk75kbkvCNxSDHw_q6FJ4sNEw%3BFS7MFgMdcJLk_ykD5mQuJTtxSDHgWC3MI4sNEw%3BFdYZFgMd7WHn_w%3BFTyvFgMdtlXq_ymvJFBAac52SDFgrE_MI4sNEw%3BFSg4FQMdGiTq_ymp-yJAfMl2SDGhNuPMI4sNEw%3BFSu4EwMd2A3s_ylFwdt-trl2SDF0LAm28EHw6A%3BFZq5EgMdyvfo_w%3BFXJ2DwMdNIvr_yn381tpGqh2SDHyCAjGbJ6ylw%3B...
...and so on

hl=en
sll=51.421477,-1.238708
sspn=0.804988,2.425232
geocode=... //this continues further

mra=dpe
mrsp=11
sz=9
via=1,2,3,4,6,7,8,10,11,12,13,14,15,16,18,19,21,22
t=m
z=8

To gain a better understanding of map parameters, you can refer to this resource:

Answer №2

Not every route point is guaranteed to be present in the URL of the new Google Maps, especially with shortened URLs.

Some time ago, I developed a tool that can transform the new Google Maps format into a gpx file.

Check it out here!

This tool is also capable of providing a JSON response.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Confirm that the input into the text box consists of three-digit numbers separated by commas

Customers keep entering 5 digit zip codes instead of 3 digit area codes in the telephone area code textbox on my registration form. I need a jQuery or JavaScript function to validate that the entry is in ###,###,###,### format without any limit. Any sugge ...

Python Selenium error: NoSuchElementException - Unable to find the specified element

Coding Journey: With limited coding knowledge, I've attempted to learn through various resources without much success. Now, I'm taking a different approach by working on a project idea directly. The goal is to create a program that interacts wi ...

Exploring the potential of utilizing the "wait" function in Selenium WebDriver for

I want to automate a test on my website using the Selenium WebDriver for JavaScript. How can I approach running tests here with content that may not be ready when the page loads, such as data coming from an external API? In my case, the content is loaded ...

In Vue js, where is the best place to incorporate something similar to a 'base.html' template?

My transition from a Flask backend without a front end framework to Vue.js (with no chosen backend yet) has me considering how to structure my project. Previously, I would create a 'base.html' file that contained all the necessary HTML code, depe ...

An inquiry regarding props in JavaScript with ReactJS

Check out the following code snippet from App.js: import React from 'react' import Member from './Member' function App () { const members = [ { name: 'Andy', age: 22 }, { name: 'Bruce', age: 33 }, { n ...

Extract data from a website with Python and selenium

I need to scrape the data from a table that seems to be generated in JavaScript. I'm using selenium and Python3 for this task. While looking at how others have approached similar challenges, I noticed they use xpath to locate the tables before scrapin ...

Tips for passing mapped data as props to a different component in a React application

I am trying to pass mapped data as props to another component. The code I have written is as follows: <div className={styles.myTeamFlex}> {userTeams.map((team, index) => ( <TeamCard key={team + index} active={active} in ...

Upon selecting multiple checkboxes, corresponding form fields will be displayed based on shared attributes

When multiple checkboxes are selected by the user, corresponding form fields should appear based on the checkboxes. For example, if both flight and hotel checkboxes are checked, then the full name and last name fields should be displayed while other fields ...

How can AngularJS utilize variables from an external JavaScript <script> file within an HTML document?

As someone unfamiliar with AngularJS, I have a simple inquiry regarding the subject. The code on my page begins by defining an app and controller: <script> var isisApp = angular.module('isisApp', []); isisApp.controller('Acco ...

Choose an option using jQuery with the ability to navigate to the previous or next

I encountered a bug when I tried to click the next or previous button. Below is the HTML code snippet: $("#nextPage").click(function() { $('#pagination option:selected').next().attr('selected', 'selected'); console.log( ...

The collapsible tree nodes overlap one another in the D3.js visualization

I'm currently working on integrating a d3 code into Power BI for creating a collapsible tree structure. Each node in the tree is represented by a rectangular box, but I've run into an issue where nodes overlap when their size is large. Below is t ...

Reveal the concealed button with a jQuery click event

I have a simple question that has been elusive to find an answer for on the internet. Can anyone please help? <input hidden="true" class="btnsubmit" id="myaddslide2" onClick="UPCURSLIDE()" type="button" value="UPDATE"> <script> function ...

What is the best way to refresh a page using Vue 3 Composition API and router?

Once confirmed in Vue 3 Composition API router.push('/IssueList'); When arriving at the IssueList page, I want my issue-incoming and issue-send components to refresh. Although I am redirecting to the page, the IssueList page does not refresh. ...

Issues with Jquery Checkboxes Functionality

Hi everyone, yesterday I had a question and since then I have made quite a few changes to my code. Right now, I am attempting to make some JavaScript work when a specific checkbox is checked. However, nothing is happening when I check the checkbox. Can any ...

Obtaining a UTC datetime value in BSON format using Node.js or JavaScript

I'm encountering an issue while attempting to save an entry in a MongoDB time series collection. The problem arises when storing the timeField, resulting in an error thrown by mongo. MongoServerError: 'blockTime' must be present and contain ...

Data is not appearing when using Node.js with mongoose and the populate() method

I am facing an issue while trying to display data from a database. Even though I have integrated 3 different schemas into one, the combined data is not being displayed as expected. I have attached all three schemas for reference. While async-await along w ...

Why are the UI components (`Card Number`, `MM/YY`, `CVC`) not being displayed in the React app when using Card

Having an issue where the CardElement Ui component is not visible in the image provided. It should appear above the Order Total: $0 next to the payment method. https://i.sstatic.net/NCK5z.png I've attempted various debugging methods without success. ...

Limiting zero is ineffective when it comes to pop-up issues

Hey there, I'm looking to prevent users from inputting zero and dot in a specific field, which is currently working fine. However, when the field is within a pop-up, the code below doesn't seem to work. <script> $('#name').keyp ...

Retrieve the data stored in an array of objects

code props.thumbnails.forEach(value=>{ console.log(value.photo.thumbnail_url); }) error TypeError: Cannot read property 'thumbnail_url' of undefined Trying to loop through props.thumbnails array and access the thumbnail_url pro ...

I want to locate every child that appears after the <body> element, and extract the HTML of the element containing a specific class within it

It may sound a bit confusing at first, but essentially I have some dynamically generated HTML that resembles the following: <body> <div class="component" id="465a496s5498"> <div class="a-container"> <div class="random-div"> ...