try something like that
google.maps.event.addListener(map, 'click', function(event) {
      addMarker(event.latLng);
    });
function addMarker(latLng){
var marker = new google.maps.Marker({
                position: latLng,
                map: map,
                title: "blub",
                bouncy: true,
                draggable: true
              })
marker.setIcon(iconForMarker);
}

done

On 3 Feb., 13:41, Rossko <ros...@culzean.clara.co.uk> wrote:
> > @Rossko: I don't get a javascript error when I click the add marker.
>
> I'll bet you do, have a closer look at your browser's error reporting
> tools.
>
> >What
> > I'm trying to achieve is that I can add a marker only if the add marker
> > button is selected.
>
> Okay, have you considered my earlier reply and how you might change
> your code?
> The order that you put lines of javascript in is quite important.
> Think about your code that creates a marker and puts it on the map, do
> you think that should execute when the user pokes the "place a
> marker"?  Would it be more approriate to have it inside the map click
> listener that you create?  What do the you think the map click
> listener you create now is actually going to do when the map is
> clicked?

-- 
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 google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to