public Cluster(int zoom, MarkerWrapper marker1, MarkerWrapper marker2) : this(zoom) { totalCount = 2; marker1.GetTilePosition(zoom, out tileX, out tileY); projection.TileToCoordinates(tileX + 0.5, tileY + 0.5, zoom, out longitude, out latitude); if (zoom < instance.clusterToZoom) { int mx1, my1, mx2, my2; marker1.GetTilePosition(zoom + 1, out mx1, out my1); marker2.GetTilePosition(zoom + 1, out mx2, out my2); if (mx1 == mx2 && my1 == my2) { AddChild(new Cluster(zoom + 1, marker1, marker2)); } else { AddChild(marker1); AddChild(marker2); } } else { AddChild(marker1); AddChild(marker2); } }
public ClusterItem Add(MarkerWrapper marker) { totalCount++; if (zoom < instance.clusterToZoom) { int mx, my; int z = zoom + 1; marker.GetTilePosition(z, out mx, out my); for (int i = 0; i < count; i++) { ClusterItem item = childs[i]; if (item.CompareTiles(z, mx, my)) { if (item is Cluster) { (item as Cluster).Add(marker); } else { Cluster c = new Cluster(z, item as MarkerWrapper, marker) { parent = this }; childs[i] = c; } return(item); } } } AddChild(marker); return(this); }