Get Directions Google Map API using JavaScript

You may also like...

4 Responses

  1. Jigar says:

    Life Saver. Thanks !

  2. jacob says:

    i want to change the color of the direction line color

    • Admin says:

      Hi Jacob,
      If you want to change the direction line color then update your existing code.
      Check below code it will be help to you. Red fonts indicated as updated code.

      Here we used Polyline property with given attributes for direction line of map.

      var polylineOptionsActual = new google.maps.Polyline({
      strokeColor: '#FF0000',
      strokeOpacity: 1.0,
      strokeWeight: 10

      function (response, status) {
      if (status == google.maps.DirectionsStatus.OK) {
      new google.maps.DirectionsRenderer({
      map: mapObject,
      directions: response,
      polylineOptions: polylineOptionsActual

      $("#lblError").append("Unable To Find Root");

      Let us know if you have any query.

      Keep in touch…
      Share articles with your friends…

  3. Erik Treat says:

    BEAUTIFUL! Wanting to change the location to an address by default without the user having to input the address in “location to”. Really like to see a list of step by step generated after selecting the “submit” button. Thank you for an AWESOME tutorial for making a Google Map using Javascript!

Leave a Reply to Jigar Cancel reply

Your email address will not be published. Required fields are marked *

− 2 = five

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">