title: How to change position of marker, created in run-time (Google Maps v3)
body: <p>I have to create several markers on Google Maps, in run-time.</p>
  
  <p>Their initial position is randomly defined.</p>
  
  <p>When they are created, how can I change position of some of them? New position is also randomly defined.</p>
  
  <p>I did tried with </p>
  
  <pre><code>marker1.setPosition(pt);
  </code></pre>
  
  <p>... but, I'm getting error </p>
  
  <pre><code>marker1 is not defined
  </code></pre>
  
  <p>I guess that problem is that marker1 is not defined in moment when map is created... Something like that.</p>
  
  <p>Can you help me how can I solve this one?</p>
  
  <p>p.s. There is no limit of how many markers will be created.</p>
  
  <p><strong>UPDATE</strong> Markers are created with:</p>
  
  <pre><code>function addNewMarker( locationsTotal ) {
  
  if (document.getElementById("lon1").value == '') document.getElementById("lon1").value = '19';
  if (document.getElementById("lat1").value == '') document.getElementById("lat1").value = '45';
  
  var parliament = (map.getCenter());
  
  var newMarker = 'marker' + locationsTotal;
  newMarker = new google.maps.Marker({
    name:newMarker,
    id:newMarker,
    map:map,
    draggable:true,
    animation: google.maps.Animation.DROP,
    position: parliament, 
    icon: 'img/pin.png'
  });
  
  google.maps.event.addListener(newMarker, "dragend", function() {
    var center = newMarker.getPosition();
    var latitude = center.lat();
    var longitude = center.lng();
    var newLon = 'lon' + locationsTotal;
    var newLat = 'lat' + locationsTotal;
    document.getElementById(newLon).value = longitude;
    document.getElementById(newLat).value = latitude;
  });
  
  }
  </code></pre>