You are creating a new marker each time someone clicks on the map. You should only create a marker on the first click and on subsequent clicks move it.
Hope this helps, Alan On Jan 2, 1:54 pm, Laythss <[email protected]> wrote: > I am trying to only allow one marker on the map, so if the visitors clicks > on one spot first and then clicks on another spot on the map the marker > dissapears from first spot and appears on the second spot. I followed the > example in :http://code.google.com/apis/maps/articles/phpsqlinfo_v3.html > > i am assuming what i have to fix is in the following lines but i am not > sure how to properly go about it: > > google.maps.event.addListener(map, "click", function(event) { > marker = new google.maps.Marker({ > position: event.latLng, > map: map}); > > google.maps.event.addListener(marker, "click", function() { > infowindow.open(map, marker); > > }); > }); > > since i think the code as it is creates a new marker everytime the map is > clicked > > i tried : > google.maps.event.addListener(map, 'click', function(event){ > marker.setPosition = event.latLng; > > }) > > but i guess i am missing something since that made my clicks on the map go > unnoticed and no marker whatsoever appears. > > the page where i have the code is on:http://www.findriyadh.com/g_addstore.php > > Any help is appreciated. Thanks in advance -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
