Saving Dragable Directions Google Directions API v3

后端 未结 2 437
情歌与酒
情歌与酒 2020-12-06 04:04

I\'m making an app with the Directions API to create biking directions. The user needs to be able to start from a custom point, add custom stopping points along the route, a

相关标签:
2条回答
  • 2020-12-06 04:17

    I was trying for saving waypoints and this should be useful to other users who are searching for the same.

    I have created set of scripts to save the directions waypoints in the database also code to fetch that information back and display the waypoints in another map. I have provided html, php and sql files and complete explanation in this link.

    http://vikku.info/programming/google-maps-v3/draggable-directions/saving-draggable-directions-saving-waypoints-google-directions-google-maps-v3.htm.

    Also you can copy the source code of that page and you can edit according to your preference and use the sql file for the database.

    0 讨论(0)
  • 2020-12-06 04:20

    UPDATE: I've found my own answer.

    The object that houses the most current map data is directionsDisplay.directions. That object holds the data from the map AS SHOWN…including the via_waypoints[] array, which shows up as a child of the legs[] array.

    The code below shows how you can print the string for your analyzing pleasure (I've made this function to be called by a button on the HTML side):

    //GET THE JSON Object
    var newString = JSON.stringify(directionsDisplay.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>";
    

    Lesson of the night: directionsDisplay.directions calls on the map data AFTER a user has made dragable changes to their directions.

    0 讨论(0)
提交回复
热议问题