Hi All,
If I correctly understood,
=> In MapClusterer for v2, center is the position of the first added
marker.
=> In MapClusterer for v3, center is an average between the previous
center and the new marker
The way the average is calculated is not strict, a barycentric
approach would give better results.
For v3 it looks like:
if (this.averageCenter_) {
var lat = (this.center_.lat()*this.markers_.length +
marker.getPosition().lat()) / (this.markers_.length+1);
var lng = (this.center_.lng()*this.markers_.length +
marker.getPosition().lng()) / (this.markers_.length+1);
this.center_ = new google.maps.LatLng(lat, lng);
this.calculateBounds_();
}
For v2 it looks like:
if (center_ === null) {
center_ = marker.marker.getLatLng();
} else {
center_ = new GLatLng(
( markers_.length*center_.lat() +
marker.marker.getLatLng().lat() )/( markers_.length+1 ),
( markers_.length*center_.lng() +
marker.marker.getLatLng().lng() )/( markers_.length+1 ) );
}
I gives nice results for me.
all the best, many thanks for your awesome work,
--
Pierre-Antoine
--
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.