On Jan 2, 11:54 am, 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.

I see markers appear where I click (what browser are you using? you
might either have a browser dependency or a bad version of your page
stuck in the browser cache.

You don't have any code to remove the old marker before creating the
new one, so they keep accumulating.

  -- Larry

>
> 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.

Reply via email to