davidrepko / google-maps-utility-library-v3

Automatically exported from code.google.com/p/google-maps-utility-library-v3
Apache License 2.0
0 stars 0 forks source link

Markercluster averageCenter bug [with solution] #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a Markercluster with averageCenter

Expected result:
the cluster to have the average center of contained markers

Actual result:
random center

Version: 1.0

There is a bug in the way the average center is calculated. Eg. if the points 
have lat = [100, 140] the center has lat 80. If the points have lat = [140, 
100] the center has lat 120. The correct formula is:

var lat = (this.center_.lat() * (l-1) + marker.getPosition().lat()) / l;
var lng = (this.center_.lng() * (l-1) + marker.getPosition().lng()) / l;

Original issue reported on code.google.com by vcausar...@gmail.com on 26 Oct 2010 at 1:49

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by lu...@google.com on 16 Nov 2010 at 12:44