title: Allow user to create only one Google Maps marker at a time
body: <p>I have the following code that allows a user to click somewhere on the map and it records the GPS location of wherever they click.  It works properly on the backend but whenever the user clicks more than once it leaves multiple markers on the map.  It always keeps whatever the last location is so it works but it is somewhat confusing for the user who doesn't know what is going on on the backend.  Is there some little trick I can do to make it so that whenever the user clicks to create a new marker the old one is removed?</p>
  
  <p>code:</p>
  
  <pre><code>    var map;
  var GPSlocation;
  
  
  function initialize() {
    var haightAshbury = new google.maps.LatLng(37.7699298, -93.4469157);
    var mapOptions = {
      zoom: 4,
      center: haightAshbury,
      mapTypeId: google.maps.MapTypeId.TERRAIN
    };
    map =  new google.maps.Map(document.getElementById("map"), mapOptions);
  
    google.maps.event.addListener(map, 'click', function(event) {
      addMarker(event.latLng);
    });
  }
  
  function addMarker(location) {
  //I save the location right here
      GPSlocation = location;
      document.getElementById("GPSlocation").value = GPSlocation;
      marker = new google.maps.Marker({
      position: location,
      map: map
    });
  }
  </code></pre>