See "Accessing Arguments in UI Events" section, in particular code example there. http://code.google.com/apis/maps/documentation/javascript/events.html#EventArguments
google.maps.event.addListener(map, 'click', function(event) { placeMarker(event.latLng); }); In your case instead of map object you will have a marker object, but it should work. To avoid creating 10k+ markers you need to figure out how can you only create those which are located within map bounds and update (or clear and re-add) all markers on the visible area when map is moved or zoomed in/out. ~Alex On Oct 16, 5:27 am, uno <radio.apo...@googlemail.com> wrote: > hello, probably only half a maps question, but if someone could > enlighten me... > what i do is: > > google.maps.event.addListener(Marker, 'click', function() { > doSomethingWith(this);}); > > function doSomethingWith(that) {...}; > > works fine. but, i have 10k+ markers, and this way i create 10k+ > objects, right? > what i'd like to do is: > > google.maps.event.addListener(Marker, 'click', doSomethingWith); > function doSomethingWith(e) {...} > > where e should be the marker object, since i have to access some of > its properties. but e is a LatLng object. > so, how to get a reference to the marker itself? > > this: > google.maps.event.addListener(Marker, 'click', > doSomethingWith(Marker)); > obviously opens the gates of hell, when used in 10k+ loops... of > course... ;) > > any idea anybody? it's not a problem anyway to use the anonymous > function above, at least no browser i've tested with had performance > problemes (markers are handled in markerClustererPlus). but i want to > save something. is it worth the effort? > thanks, uno -- 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.