Richard - The documentation does say that the directionsResult is in JSON, but as you found out it is actually an object. After reading your note, I tried stringify-parse on a directionsResult, and when I did it Firefox threw "Invalid value for property <position>". So I, too, was unable to stringify the directionsResult.
But you shouldn't have to do that. Save all the points in the via_waypoint[] array, and then to reconstruct the route don't just build a polyline (that would only be point-point by waypoints anyway), but feed that array back into the directionsService. The directionsService will build the same directionsResult, because you are giving it the same waypoints. There is one gotcha; you are limited to 8 intermediate waypoints, and you may have dragged in more. But this is easy to work around. Directions are transitive, so you just need to break up your string of waypoints into chunks of 8, and then reconstruct the resulting route in your own directionsRenderer. On Oct 25, 3:31 am, Richard <richard.as...@gmail.com> wrote: > Hello, > > I am trying to save the DirectionsResult object that has been > dragged. I want to be able to reload it another time and allow the > route to be edited further. > > I can save all of the points in the via_waypoint[] array. This allows > be to redraw the route as a polyline but it is no longer draggable. > > The documentation says that the DirectionsResult is returned in JSON > format. So I've tried to convert the DirectionsResult to a JSON > string, save and reload that string as a JSON object and pass it to > the DirectionsRenderer. But it doesn't display and no errors are > thrown. > > Below is a sample of what I was trying to do. > > directionsService.route(request, function(response, status) { > if (status == google.maps.DirectionsStatus.OK) { > var str = JSON.stringify(response)) > var obj= JSON.parse(str) > directionsDisplay.setDirections(obj); > } > > I am presuming that this is possible as Google MyMaps provides this > functionality. > > Any help would be gratefully appreciated. > > Thanks -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to google-maps-js-api...@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.