googlearchive / js-marker-clusterer

A marker clustering library for the Google Maps JavaScript API v3.
https://googlemaps.github.io/js-marker-clusterer/docs/reference.html
Apache License 2.0
1.28k stars 775 forks source link

Adding your own calculator, correct method? #42

Open mistyn8 opened 8 years ago

mistyn8 commented 8 years ago

A little confused about overriding the calculator...

should it be as per the example here http://gmaps-utility-library-dev.googlecode.com/svn/trunk/markerclusterer/examples/simple_example_with_values.html

eg passed in as a option on instantiation.. var markerCluster = new MarkerClusterer(map, markers, {'calculator': average});

or using the markerCluster.setCalculator(function(markers, numStyles) {...});

I couldn't seem to get the example method to work, but assume there might be an overhead setting after instantiation?

kesha-antonov commented 8 years ago

Hey! If it's ok to have calculator globally, you can override function like this:

MarkerClusterer.prototype.calculator_ = function(markers, numStyles) {
...

coffeescript:

MarkerClusterer::calculator_ = (markers, numStyles) ->
...