title: How to avoid U-turns while drawing routes on google map?
body: <p>I am using Google Map's Direction service to draw the driving path between two markers. I am using the below code and it is drawing the path. But there is one small issue, as in if the marker is present at the left side of the road and the path is drawn from the right side, then the route draw is getting u-turn from the next round about which I don't want to happen. The route should stop as soon as it reaches without any u-turns irrespective of the direction of the path drawn. Need help on this change.</p>
  
  <pre><code>for ( var i = 0; i &lt; realtracPath.length - 1; i++) {
          var startPos = new google.maps.LatLng(realtracPath[i].lat,
                  realtracPath[i].lng);
          var endPos = new google.maps.LatLng(realtracPath[i + 1].lat,
                  realtracPath[i + 1].lng);
          var request = {
              origin : startPos,
              destination : endPos,
              travelMode : google.maps.TravelMode.DRIVING
          };
          directionsService
                  .route(
                          request,
                          function(result, status) {
                              if (status == google.maps.DirectionsStatus.OK) {
                                  for ( var i = 0, len = result.routes[0].overview_path.length; i &lt; len; i++) {
                                      path
                                              .push(result.routes[0].overview_path[i]);
                                  }
                                  poly.setPath(path);
                              }
                          });
      }
  </code></pre>
  
  <p>Thanks.</p>