title: Google Maps JavaScript API v3 drawing line between two location
body: <p>please help me on this, I really stuck on this!
  my code is:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no"&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Geocoding service&lt;/title&gt;
      &lt;style&gt;
        html, body, #map-canvas {
          height: 100%;
          margin: 0px;
          padding: 0px
        }
        #panel {
          position: absolute;
          top: 5px;
          left: 50%;
          margin-left: -180px;
          z-index: 5;
          background-color: #fff;
          padding: 5px;
          border: 1px solid #999;
        }
      &lt;/style&gt;
      &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt;
      &lt;script&gt;
  var geocoder;
  var map;
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var mapOptions = {
      zoom: 8,
      center: latlng
    }
    map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
  }
  
  function codeAddress() {
    var address = document.getElementById('address').value;
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: map,
            position: results[0].geometry.location
        });
      } else {
        alert('Geocode was not successful for the following reason: ' + status);
      }
    });
  
    var address2 = document.getElementById('address2').value;
    geocoder.geocode( { 'address2': address2}, function(results2, status2) {
      if (status2 == google.maps.GeocoderStatus.OK) {
  
        var marker2 = new google.maps.Marker({
            map: map,
            position: results2[0].geometry.location
        });
      } else {
        alert('Geocode was not successful for the following reason: ' + status);
      }
    });
  
    var myTrip = [address,address2];
      var flightPath = new google.maps.Polyline({
        path:myTrip,
        strokeColor:"#00F",
        strokeOpacity:0.8,
        strokeWeight:2
    });
  
  flightPath.setMap(map);
  }
  
  
  google.maps.event.addDomListener(window, 'load', initialize);
  
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id="panel"&gt;
        &lt;input id="address" type="textbox" value="address 1"&gt;
        &lt;input id="address2" type="textbox" value="address 2"&gt;
        &lt;input type="button" value="Geocode" onclick="codeAddress()"&gt;
      &lt;/div&gt;
      &lt;div id="map-canvas"&gt;&lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to enter two address in the input, convert it to lat/long separately, put two markers on the map and draw a straight line between them!
  my code is not working, it's displaying only the first address and that's all...
  thank you in advance!</p>