title: API V3 Update marker position dynamically
body: <p>I have this code that reads data from an xml file and puts the marker on the map.</p>
  
  <p>What i want to do is to read the xml file automatically every 5 seconds, and so update the position of the marker.</p>
  
  <p>I tried adding setInterval to the function, but the problem is that the previous marker is not deleted. Just add another  marker to the map and so on.</p>
  
  <p>(I dont want the entire map updated, just the marker)</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  
  
  var map = null;
  
  
  
  function createMarker(latlng, html) {
  var contentString = html;
  
  var image = new google.maps.MarkerImage('http://www.google.com/mapfiles/markerA.png',
  new google.maps.Size(20, 34),
  new google.maps.Point(0,0),
  new google.maps.Point(10, 34));
  
  var shadow = new google.maps.MarkerImage('http://www.google.com/mapfiles/shadow50.png',
  new google.maps.Size(37, 34),
  new google.maps.Point(0,0),
  new google.maps.Point(10, 34));
  
  var marker = new google.maps.Marker({
  position: latlng,
  map: map,
  shadow: shadow,
  icon: image,
  zIndex: Math.round(latlng.lat()*-100000)&lt;&lt;5
  
  
  });
  
  google.maps.event.addListener(marker, 'click', function() {
  infowindow.setContent(contentString); 
  infowindow.open(map,marker);
  
  });
  
  }
  
  
  
  
  function initialize() {
  
  var myOptions = {
  zoom: 13,
  center: new google.maps.LatLng(-18.432713,-70.317993),
  mapTypeControl: true,
  mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
  navigationControl: true,
  mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  
  map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
  
  
  
  google.maps.event.addListener(map, 'click', function() {
  infowindow.close();
  });
  
  
  
  setInterval(function() { 
  downloadUrl("data.xml", function(doc) {
  
  var xmlDoc = xmlParse(doc);
  
  var markers = xmlDoc.documentElement.getElementsByTagName("marker");
  
  for (var i = 0; i &lt; markers.length; i++) {
  
  var lat = parseFloat(markers[i].getAttribute("lat"));
  
  var lng = parseFloat(markers[i].getAttribute("lng"));
  
  var point = new google.maps.LatLng(lat,lng);
  
  var html = "&lt;strong&gt;Taxi Arica&lt;/strong&gt;&lt;/br&gt;&lt;strong&gt;Latitud:&lt;/strong&gt; " +       markers[i].getAttribute("lat") + "&lt;/br&gt;&lt;strong&gt;Longitud:&lt;/strong&gt; " +  markers[i].getAttribute("lng");
  
  var marker = createMarker(point,html);
  
  }
  
  });
  
  },5000);
  
  
  }
  
  
  
  var infowindow = new google.maps.InfoWindow(
  {size: new google.maps.Size(150,50)});
  
  
  &lt;/script&gt; 
  </code></pre>