It is a scope problem. Your marker is only defined in your geocode result functions, but you are trying to assign the click event outside of those functions. To fix the issue, move your click event handler into your geocode result functions.
Chad Killingsworth On Jul 9, 4:24 am, 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.
