Don't bother trying to save the directionResult. All you need is to
save the user entered waypoints (you already have those), PLUS the
waypoints created by Google when the user dragged the route. The
waypoints created by dragging are an array of objects found in
currentDirections.routes[0].legs[0].via_waypoint[]. The objects have
attributes location, step_index and step_interpolation; all you'll
need is location if the user entered only a start and end (because all
the via_waypoints will be between the start and end).
When re-displaying the saved route, the request to the
directionsService will include the waypoints property (referred to in
the documentation as "intermediate" waypoints). Since you are using
the "same" waypoints, you will get the same route.
In the "free" API you are limited to 8 intermediate waypoints to the
directionsService, yet the user is allowed to create more than 8
"vias" by dragging. To work around this just remember that directions
are "transitive" (A>B>C is the same as A>B followed by B>C), and break
the route into as many segments as needed to avoid exceeding 8
intermediate waypoints.
The via_waypoint does not appear to be documented, which means that it
could suddenly disappear. You've been warned.
(Then, of course, you have to send the retrieved waypoints back to
your server to get them into the database, and retrieve waypoints from
the database to generate the new page, but you probably have that part
completed already.)
On Oct 5, 11:54 am, David Violette <
davidaviole...@gmail.com> wrote:
> Did you find an answer to saving in database yet? I am looking for same type
> solution.