Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4084358
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:25:47+00:00 2026-05-20T18:25:47+00:00

I am working on a project and am at a point where I am

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:25:48+00:00Added an answer on May 20, 2026 at 6:25 pm

    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:

    directionsDisplay = new google.maps.DirectionsRenderer({
        'map': map,
        'preserveViewport': true,
        'draggable': true
    });
    

    in your initialisation function

    this is part of my JS:

    var currentDirections;
    var directionsDisplay;
    var waypoints = [];
        function saveWaypoints()
        {
            waypoints = [];
            var waypts_field = document.getElementById('waypoints').value.split(';');
            for(var bo = 0; bo < waypts_field.length; bo++)
            {
                if(waypts_field[bo] == ' ' || waypts_field[bo] == '')
                {
                    waypts_field.splice(bo,1);
                    bo -= 1;
                    continue;
                }
    
                waypoints.push({ location: waypts_field[bo], stopover: false });
            }
        }
    
    
        function getWaypoints()
    {
        currentDirections = directionsDisplay.getDirections();
        var route = currentDirections.routes[0];
        totalLegs = route.legs.length;
        for (var i = 0; i < route.legs.length; i++) {
            var routeSegment = i+1;
            if(route.legs[i].via_waypoint[0] === undefined) continue;
    
            document.getElementById('waypoints').value = '';
            var via_waypoint_count = route.legs[i].via_waypoint.length;
            queue = 0;
            for(var bi = 0; bi < via_waypoint_count; bi++)
            {
                var count = 0;
    
                var lat;
                var lng;
    
                for (key in route.legs[i].via_waypoint[bi]['location'])
                {
                    if(count > 1) break;
                    if(count == 0)
                    {
                        lat = route.legs[i].via_waypoint[bi]['location'][key];
                        count++;
                        continue;
                    }
                    lng = route.legs[i].via_waypoint[bi]['location'][key];
    
                    count++;
                }
                reverseGeoCode(new google.maps.LatLng(lat,lng));
            }
        }
    }
    
            function reverseGeoCode(latlng)
        {
            queue += 60;
            setTimeout(function(){
            geocoder.geocode({ 'latLng': latlng }, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                if (results[1]) {
                  document.getElementById('waypoints').value += results[1].formatted_address + '; ';
                }
              } else {
                alert("Geocoder failed due to: " + status);
              }
            });
            }, queue * 10);
        }
    

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on project that lets users choose some scientific authors and columnists and
Im working on a project and I need to output floating point values using
I am working a project with many NUnit tests, that were already written long
I have a fully working Setup project within Visual Studio 2008 that takes inputs
I'm working on a project that is to simulate many functions seen in Microsoft
I'm again working on Project Euler, this time problem #4. The point of this
I am working on a project that requires me to separate out each color
I am working on a project to generate some KML data from our delivery
I am working on a project where at one point I am stuck. My
I'm working on a project that requires that the vertical borders, which are currently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.