title: setTimeout() and dropping markers on google map
body: <p>I don't understand why setTimeout is not working as I expected.</p>
  
  <p>I want to drop each marker on a different time, not all at the same time.</p>
  
  <p>Paste and run this code into <a href="http://jsfiddle.net" rel="nofollow noreferrer">http://jsfiddle.net</a>, then remove comments in order to see the funny behavior:</p>
  
  <pre><code>        //setTimeout(function() {
              addMarker(m);
          //}, i * 500);
  </code></pre>
  
  <p>.</p>
  
  <pre><code>&lt;link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" /&gt;
  &lt;script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=false"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
    var berlin = new google.maps.LatLng(52.520816, 13.410186);
    var neighborhoods = [
      new google.maps.LatLng(52.511467, 13.447179),
      new google.maps.LatLng(52.549061, 13.422975),
      new google.maps.LatLng(52.497622, 13.396110),
      new google.maps.LatLng(52.517683, 13.394393)
    ];
    var map;
    function initialize() {
      var mapOptions = {
        zoom: 12,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        center: berlin
      };
      map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
    }
  
    function drop() {
      var j = 0;
      for (var i = 0; i &lt; neighborhoods.length; i++) {
          var m = neighborhoods[i];
          //setTimeout(function() {
              addMarker(m);
          //}, i * 500);
      }
    }
    function addMarker(m) {
      new google.maps.Marker({
        position: m,
        map: map,
        draggable: false,
        animation: google.maps.Animation.DROP
      });
    }
  &lt;/script&gt;
  &lt;body onload="initialize()"&gt;
  &lt;div id="map_canvas" style="width: 500px; height: 400px;"&gt;map div&lt;/div&gt;
  &lt;button id="drop" onclick="drop()"&gt;Drop Markers&lt;/button&gt;
  &lt;/body&gt;
  </code></pre>