I am working on a project and am at a point where I am unable to go any further and need some serious assistance. Let me give you some background.
I am working on a service that will let users riding bikes to the
same destination from multiple starting points coordinate their rides.
Part of the workflow we’ve designed has users building maps using the
Google Maps service; they enter a starting destination, Google creates
a route it thinks will work, and then users can tailor that route by
dragging points to meet their particular needs. We have this
interface developed and working nicely at:
http://ridestreaming.com/google_maps/
Where I’ve hit an impassable wall is in how to get the user-edited
route out of Google Maps and saved in the database for future
reference. It seems like we have a method for doing that in our
Javascript, in this file (lines 344-352):
http://ridestreaming.com/google_maps/workflow.js
var newString = JSON.stringify(directions);
//set up area to place drop directionsResponse object string
var directions_response_panel = document.getElementById("directions_response");
//dump any contents in directions_response_panel
directions_response_panel.innerHTML = "";
//add JSON string to it
directions_response_panel.innerHTML = "<pre>" + newString + "</pre>";
//run the ajax
runAjax(directions);
We can get the route data out as a JSON file, stringify it, and send
it via AJAX to a PHP file where we intend to process it and store it
in MySQL. However, the JSON being returned from Google Maps appears
to be malformed; PHP freaks out when it tries to decode it, and I ran
it through a validator online which confirmed its malformness. It is
at this point that we are completely baffled and have no idea how to
move forward.
Is there any chance this anybody might be able to assist with this? I am at the point of bashing my head against a wall. Any response at all is greatly appreciated. Thanks for your time!
I have been doing similar thing and found this really difficult however after several hours of hard work, I managed to get all waypoints from User-Dragged route and save it into database..
So, I have a field that holds all waypoints separated by “;”.
You have to have this:
in your initialisation function
this is part of my JS:
i quickly pulled this off my JS, so if it does not make sense, I will post all of my JS and explain it bit by bit..
Thanks