private void AddStoreMarkerToCluster(MapCluster cluster, IGeoCoordinate store)
        {
            var storeCoordinate = store.GetCoordinate();

            if (cluster.Center == null)
            {
                cluster.Center = storeCoordinate;
            }
            else
            {
                var l   = cluster.ItemsCount + 1;
                var lat = (cluster.Center.Lat * (l - 1) + storeCoordinate.Lat) / l;
                var lng = (cluster.Center.Lng * (l - 1) + storeCoordinate.Lng) / l;
                cluster.Center = new Coordinate(lat, lng);
            }

            var xScale = ZoomLngScales[ZoomLevel];
            var yScale = ZoomLatScales[ZoomLevel];

            cluster.Tile = new Bounds(new Coordinate(cluster.Center.Lat - yScale / 2, cluster.Center.Lng - xScale / 2),
                                      new Coordinate(cluster.Center.Lat + yScale / 2, cluster.Center.Lng + xScale / 2));


            cluster.ItemsCount++;
            cluster.StoreNumber = cluster.ItemsCount == 1 ? store.Id : cluster.StoreNumber + ";" + store.Id;
        }
        private void AddToClosestCluster(ClusteringContext context, IGeoCoordinate store)
        {
            var clusterToAdd = context.Clusters.FirstOrDefault(cluster => InBounds(cluster.Tile, store));

            if (clusterToAdd != null)
            {
                AddStoreMarkerToCluster(clusterToAdd, store);
            }
            else
            {
                clusterToAdd = new MapCluster {
                    SearchIndex = context.Clusters.Count + 1
                };
                AddStoreMarkerToCluster(clusterToAdd, store);
                context.Clusters.Add(clusterToAdd);
            }
        }
Exemple #3
0
 private void OnClusterTapped(MapCluster sender, Object args) => Frame.Navigate(typeof(PhotoListPage), sender.Objects);