0
votes

I have a google maps URL, such as: https://www.google.com/maps/dir/New+Jersey/New+York,+NY/@40.4831065,-74.2922059,10.5z/data=!4m39!4m38!1m30!1m1!1s0x89c0fb959e00409f:0x2cd27b07f83f6d8d!2m2!1d-74.4056612!2d40.0583238!3m4!1m2!1d-74.4153412!2d40.3648316!3s0x89c3daa461aa3c93:0x7b560d06adda6be!3m4!1m2!1d-74.3723857!2d40.4122069!3s0x89c3cfa79a40a597:0xe14c3da961c44c2!3m4!1m2!1d-74.3509894!2d40.4455723!3s0x89c3ced3fbbe73ed:0xbd025b74a14968a3!3m4!1m2!1d-74.3046099!2d40.4577947!3s0x89c3cbe43ca0145b:0xa91af0f94409e6cd!3m4!1m2!1d-74.3736178!2d40.5948195!3s0x89c3b73da97c2b15:0x97196198a790abf9!1m5!1m1!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62!2m2!1d-74.0059413!2d40.7127837!3e0

As you can see, I've changed the original path. GMaps, therefore, also changes data param in order to reflect the changes I made in the route when I dragged and dropped but it does not add waypoints.

There also exists directions api (https://maps.googleapis.com/maps/api/directions/json), and, theoretically, I could retrieve a JSON object for the same route and passing origin, destination, and waypoints.

However, because I dragged and dropped the route in the way, the JSON I'm getting does not follow the path I plotted, once the URL did not change waypoints param but changed data parameter.

Let me place an example here of how the api would be called: https://maps.googleapis.com/maps/api/directions/json?origin=New+Jersey&destination=New+York,+NY

As you can see here, no waypoints because they were dragged.

How do I add data param into the JSON object to reflect the changes?

1
You need to add the waypoints to the request. - geocodezip
I have added waypoints but when you drag the route, the difference goes into data param, therefore the JSON object does not reflect the real route i'm trying to retrieve. - Eduardo Kasper
I'm not sure what that means, could you clarify in your question? - geocodezip
Hi, I have changed it. Please reread the question. Hope its better to understand now - Eduardo Kasper

1 Answers

0
votes

Apparently, there's no way to add data param to the request when retrieving JSON object. Therefore, the solution I found was to add more Renderers to the map, once there's no limit towards that service.

Also, 8 waypoints is the limit. No way to add more than that when using Direction Service.

Hope it's of some use.