Hi Harry,

Your "var marker" is done inside a "if" block. You need to declare
your variable at the top of the initialize function if you want
"marker" to be visible below the "if" block. So write :

  var marker;

  if (geocoder) {
    (...)
    marker = new google.maps.Marker({
                                map: map,
                                position: zentrum,
                                title: adresse
                            });
    (...)
  }

  google.maps.event.addListener(marker, 'click', function(event) {
    marker.setMap(null);
  });

Hope this helps.

Grégoire

On 9 juil, 11:24, Harald Effenberg <[email protected]> wrote:
> Hi!
>
> I have a problem in line 168 onhttp://www.effenberg.de/maps-v3-e.htm
>
> "marker is not defined"
>
> The code is
>
>     google.maps.event.addListener(marker, 'click', function(event)
>     {
>     marker.setMap(null);
>     });
>
> But there is always a marker if I remove those lines, no matter if it
> is at it's default place onhttp://www.effenberg.de/maps-v3.htm
> or at a variable place on i.e.http://www.effenberg.de/maps-v3.htm?mainstreet
>
> The markers are in both cases created before the eventlistener is
> added, so how can "marker" be undefined?
> How can I remove a marker by a mouseclick on it?
>
> TIA and best regards
> Harry

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