Esempio n. 1
0
 /// <summary>
 /// Adds the pins from the given container
 /// </summary>
 public void Merge(PushpinContainer container)
 {
     foreach (var pin in container._pushpins)
     {
         _pushpins.Add(pin);
     }
 }
Esempio n. 2
0
        private async void RenderPins()
        {
            var pinsToAdd = new List <PushpinContainer>();

            foreach (var pin in _pins)
            {
                Point screenLoc;
                _map.TryLocationToPixel(new Location(pin.Latitude, pin.Longitude), out screenLoc);

                var  newPinContainer = new PushpinContainer(pin, screenLoc);
                bool addNewPin       = true;

                foreach (var pinContainer in pinsToAdd)
                {
                    double distance = ComputeDistance(pinContainer.ScreenLocation, newPinContainer.ScreenLocation);

                    if (distance < _distanceTreshold)
                    {
                        pinContainer.Merge(newPinContainer);
                        addNewPin = false;
                        break;
                    }
                }

                if (addNewPin)
                {
                    pinsToAdd.Add(newPinContainer);
                }
            }

            await _map.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                var items = new List <IGeoCluster>();
                foreach (var projectedPin in pinsToAdd.Where(pin => PointIsVisibleInMap(pin.ScreenLocation, _map)))
                {
                    items.Add(projectedPin.GetCluster());
                }

                _mapItemsControl.ItemsSource = items;
            });
        }