The latter pattern is more efficient, with 1 modification. Rather than creating a listener function in each call to .addListener(), create your listener function once and add that same listener to all markers. Reducing the number of Objects like this helps older browsers especially.
On 12 Jul 2010 07:18, "uno" <[email protected]> wrote: > hello, > when loading 6000+ markers on a map, each one has a click-listener > with individual data (i.e. a numeric id and a string), what would be > the best approach, performance-wise: > > to assign the data within the listener individualy, e.g. > > var id = ... > var title = ... > google.maps.event.addListener(Marker, 'click', function() { > alert("data: " + id + ", " + title); > }); > > or register the data as a property in the marker and assign the > listener like this: > > Marker.id = ... > Maker.title = ... > google.maps.event.addListener(Marker, 'click', function() { > alert("data: " + this.id + ", " + this.title); > }); > > does it make a difference? > thx, 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 [email protected]. > To unsubscribe from this group, send email to [email protected]<google-maps-js-api-v3%[email protected]> . > For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en. > -- 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.
