title: how to move markers in google map API?
body: <p>I want to move 2 markers on the same google map but i can't find the problem in my code. I can move the 1st marker but i can't move the second one, it is possible to move two markers at the same time on the same map?
  How i can move 2 markers at the same time?</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;HTML5&lt;/title&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;meta name="viewport" content="width=650, user-scalable=yes"&gt;
      &lt;script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"&gt;&lt;/script&gt;
      &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;style&gt;
        html, body {
          height: 100%;
          margin: 0;
        }
  
        #mapcanvas {
          height: 97%;
        }
  
        #info {
          width: auto;
          margin: 5px;
          height: 3%;
        }
      &lt;/style&gt;
  
      &lt;script&gt;
        var map;
        var latLonList = [
          { lat: 45.54169245190391, lon: -73.53928729891777 },
          { lat: 45.54173002374242, lon: -73.53945091366768 },
          { lat: 45.541743173879944, lon: -73.53949382901192 },
          { lat: 45.541790138631775, lon: -73.53962525725365 },
          { lat: 45.541844617694764, lon: -73.53980496525764 },
          { lat: 45.54189721811927, lon: -73.5399578511715 },
          { lat: 45.54193666840536, lon: -73.5401026904583 },
          { lat: 45.54198363299557, lon: -73.5402475297451 },
          { lat: 45.542068169159045, lon: -73.5405720770359 },
          { lat: 45.54214706946365, lon: -73.54082688689232 },
          { lat: 45.54222221250792, lon: -73.54105487465858 },
          { lat: 45.54226729828628, lon: -73.54119434952736 },
          { lat: 45.54235746973452, lon: -73.54123994708061 },
          { lat: 45.542543447889805, lon: -73.5411112010479 },
          { lat: 45.542718154081314, lon: -73.54099586606026 },
          { lat: 45.54289661683465, lon: -73.54089394211769 },
          { lat: 45.54298866582284, lon: -73.54103341698647 },
          { lat: 45.54308071466031, lon: -73.54133650660515 },
          { lat: 45.543180277518914, lon: -73.5413445532322 },
          { lat: 45.54330050413203, lon: -73.54127749800682 },
          { lat: 45.54337001002545, lon: -73.54111924767494 }
        ]
  
        $(document).ready(function () {
          var mapOptions = {
            zoom: 13,
            center: new google.maps.LatLng(43, 0),
          };
  
          map = new google.maps.Map($('#mapcanvas')[0], mapOptions);
  
          //*********************************************************************
          // Add the layer showing the inventory
          //*********************************************************************
  
          var marker = null;
          var markerTwo = null;
          var i = 0;
          var j = 1;
  
          function autoUpdate() {
            navigator.geolocation.getCurrentPosition(function (position) {
  
              var newPoint = new google.maps.LatLng(latLonList[i].lat, latLonList[i].lon);
  
              var secondPoint = new google.maps.LatLng(latLonList[j].lat, latLonList[j].lon);
  
  
              if (marker) {
                // Marker already created - Move it
                marker.setPosition(newPoint);
              }
              else {
                // Marker does not exist - Create it
                marker = new google.maps.Marker({
                  position: newPoint,
                  map: map,
                  draggable: true
                });
              }
  
              if (markerTwo) {
                // Marker already created - Move it
                markerTwo.setPosition(secondPoint);
              }
              else {
                // Marker does not exist - Create it
                markerTwo = new google.maps.Marker({
                  position: secondPoint,
                  map: map,
                  draggable: true
                });
              }
  
              map.setCenter(newPoint);
            });
  
            // Call the autoUpdate() function every 5 seconds
            setTimeout(autoUpdate, 3000);
            if (i == 20) {
              i = 0
            }
            else {
              i++;
            }
          }
  
          if (j == 19) {
            j = 0
          }
          else {
            j++;
          }
          autoUpdate();
        });//end document ready
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id="info"&gt;trying to update location every 5 secs   -  new latitude longitude :  &lt;span id="coordinates"&gt;&lt;/span&gt;&lt;/div&gt;
      &lt;div id="mapcanvas"&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>