title: Unable to calculate road distance using Google Maps API v3
body: <p>I get two errors while running the below code:
  1. Uncaught InvalidValueError: invalid argument to setPosition: [object Object] 
  2. Uncaught TypeError: Cannot call method 'contains' of undefined</p>
  
  <p><strong>EDIT:</strong> Can I use the same marker label to create multiple markers as I have done below?</p>
  
  <p>Basically trying to add Markers to a set of lat-longs and calculate distance to a common point:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          var map;
          var mapOptions;
          var lat = [33, 34, 35, 36];
          var lon = [-84, -86, -89, -100];
          var src = [30, -90];
          var dist = [];
          var marker;
          var directionsService = new google.maps.DirectionsService();
          var directionsRequest;
          var directionsRenderer;
          var markerPoints =  [{"location": new google.maps.LatLng(lat[0], lon[0])}, 
                               {"location": new google.maps.LatLng(lat[1], lon[1])},
                               {"location": new google.maps.LatLng(lat[2], lon[2])},
                               {"location": new google.maps.LatLng(lat[3], lon[3])}];
  
            function initialize() {
              directionsRenderer = new google.maps.DirectionsRenderer();
              mapOptions = {
                center: new google.maps.LatLng(33.75, -84.39),
                mapTypeId: google.maps.MapTypeId.ROADMAP
              };
              map = new google.maps.Map(document.getElementById("map-canvas"),
                      mapOptions);
              directionsRenderer.setMap(map);
  
              marker = new google.maps.Marker({
                   position: new google.maps.LatLng(src[0], src[1]),
                   //icon: 'http://maps.google.com/mapfiles/marker.png',
                   map: map
                });
  
              for(var iter = 0; iter &lt; lat.length; iter++)
              {
                  placeMarker(iter);
                  getDistances(iter);
              }
            }
  
            function placeMarker(iter)
            {
                   marker = new google.maps.Marker({
                   position: markerPoints[iter],
                   //icon: 'http://maps.google.com/mapfiles/marker_green.png',
                   map: map
                });
            }
  
            function getDistances(iter)
            {
                directionsRequest = {
                      origin: new google.maps.LatLng(src[0], src[1]),
                      destination: markerPoints[iter],
                      travelMode: google.maps.TravelMode.DRIVING,
                };
  
                directionsService.route(directionsRequest, function(response, status){
                    if(status == google.maps.DirectionsStatus.OK)
                        {
                              dist.push(response.routes[0].legs[0].distance);
                        }
                    else
                        {
                          alert("Impossible");
                        }
                });
            }
  
          google.maps.event.addDomListener(window, 'load', initialize);
          &lt;/script&gt;
  </code></pre>