views:

27

answers:

1

Hey Guys,

I've got the following onClick function...

     GEvent.addListener(map, "click", function(overlay, latLng)
{
    if (latLng) {
 marker = new GMarker(latLng, {draggable:true});
 marker.openInfoWindowHtml(mes);
  }
  // display the lat/lng in your form's lat/lng fields
    document.getElementById("lat").value = latLng.lat();
    document.getElementById("lng").value = latLng.lng();

});

basically I want to make it so only a marker shows on the most recent click. I've been looking at this question http://stackoverflow.com/questions/1409939/googlemaps-removing-previous-marker but can't really figure out how I'd apply that to my code. could someone help me out?

Thanks.

+1  A: 

One could use a variable within an object, and determine whether that variable has been set where it tracks the current marker that is visible, and set the marker to be invisible, unset it before adding the marker that is currently being shown.

CrazyEnigma