Search code examples
google-mapsgoogle-directions-api

Can we use overview_polyline into waypoints of particular route duration


I am using google direction service API to get route and it's distance with route drag option.

For example if i create a route between A & B. then i have dragged the original google given path to my own.

then i need to save my custom route (dragged route) and show the future reference.

In that case can i use overview_polyline (direction response json node value) into waypoints to show exact my custom route.

Please help me


Solution

  • Sure, you can store the overview_polyline and later use it to draw a polyline which will restore your customized route.

    To do this you will need a geometry library and call a google.maps.geometry.encoding.decodePath() method to get the array of your points.

    After that you can use this array to construct a Polyline object.

    Please have a look at this sample code:

    http://jsbin.com/kijaze/1/edit?html,output