Google Map polyline issue
<p>I want to add a poly line between two points on a Google map. Below is the code that I have, which is not working. Any help will be highly appreciated.</p>

<pre><code>   var distance; 
   var map;

      var geocoder;
      var cal;

      var bounds = new google.maps.LatLngBounds();

      var markersArray = [];
        var mypolyArray = [];

      var origin1 = document.getElementById("origins").value;

      var destinationA = document.getElementById("destinations").value;

      function initialize() {

         var opts = {

      center:  new google.maps.LatLng(38.6272222 , -90.1977778),
          zoom: 9,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };

  map = new google.maps.Map(document.getElementById('map'), opts);

        geocoder = new google.maps.Geocoder();

      }

      function calculateDistances() {

        var service = new google.maps.DistanceMatrixService();

        service.getDistanceMatrix(

          {
            origins: [document.getElementById("origins").value],

            destinations: [document.getElementById("destinations").value],

            travelMode: google.maps.TravelMode.DRIVING,

            unitSystem: google.maps.UnitSystem.IMPERIAL,

            avoidHighways: false,

            avoidTolls: false

          }, callback);


      }


      function callback(response, status){

   if (status == google.maps.DistanceMatrixStatus.OK) {

     var origins = response.originAddresses;

    var destinations = response.destinationAddresses;

     for (var i = 0; i &lt; origins.length; i++) {

       var results = response.rows[i].elements;


      for (var j = 0; j &lt; results.length; j++) { 
        var element = results[j];

         distance = element.distance.text;

         var duration = element.duration.text;

                  document.getElementById("distance").value = results[0].distance.text;
    document.getElementById("duration").value = results[0].duration.text;

         var from = origins[i];

        var to = destinations[j];


var outputDiv = document.getElementById('outputDiv');

 var outputDiv1 = document.getElementById( 'outputDiv1');

          outputDiv.innerHTML = 'Lambert';

           outputDiv1.innerHTML = ' ';



          for (var i = 0; i &lt; origins.length; i++) {

            var results = response.rows[i].elements;

            addMarker(origins[i], true);

            for (var m = 0; m &lt; results.length; m++) {

              addMarker(destinations[m], true);

//----------------------------------------------------

              for (var i = 0; i &lt; origins.length; i++) {

            var results = response.rows[i].elements;

            addpoly(origins[i], true);

            for (var m = 0; m &lt; results.length; m++) {

              addpoly(destinations[m], true);
</code></pre>

<p>Here i want to add a polyline which can connect two points, the points will be the input given by the user.
It shows up markers (icon), but do not run a line. It is my very first experience for developing a web, and never worked with google api's. As they say it is a javascript but to me it looks more dot net code. i do not know, i have read some books about HTML and javascripts, never found and function starting from "({". so i am confused. This code i have copied from other forum and made little changes, which are working now only  thing which is left is to add a line. The issue for me is to provide a 'path', can you please help me to specify a path for the polyline.
Thank You
Regards.</p>

<pre><code>              outputDiv.innerHTML += results[m].distance.text +"&lt;br /&gt;";
              outputDiv1.innerHTML += results[m].duration.text;


        }
          }


      }
     }
   }
     }

       } }

      function addMarker(location, isDestination) {


      geocoder.geocode({'address': location}, function(results, status) {


          if (status == google.maps.GeocoderStatus.OK) {


            bounds.extend(results[0].geometry.location);

            map.fitBounds(bounds);

           var image = "http://chart.apis.google.com/chart?chst=d_map_xpin_icon&amp;chld=pin|bank-dollar|52B552";

            var marker = new google.maps.Marker({

            icon:image,

                map:map,

                    position: results[0].geometry.location,     

            });

            markersArray.push(marker);

          }

 else {


            alert("Geocode was not successful for the following reason: "
              + "status");
          }

        });
      }
</code></pre>
