Share via

WPF bingMAP Pushpin Clusterer

驚鏵 1 Reputation point
2021-05-13T15:46:18.09+00:00

wpf bing map Pushpin polymerization
How to achieve point aggregation?
96452-%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE-20210513234354.png

如何实现Pushpin 聚合。

Developer technologies | Windows Presentation Foundation
Windows for home | Windows 11 | Apps
0 comments No comments

1 answer

Sort by: Most helpful
  1. DaisyTian-1203 11,651 Reputation points Moderator
    2021-05-14T03:16:59.527+00:00

    Do you want to get the collection of Pushpin? How did you add Pushpin? I will show you my demo of getting collection of Pushpin, and if it doesn't help you, please let me. I use ObservableCollection<Pushpin> Pushpins to store the Pushpin.

    int counter = 0;  
            ObservableCollection<Pushpin> Pushpins = new ObservableCollection<Pushpin>();  
      
            public MainWindow()  
            {  
                InitializeComponent();  
                myMap.MouseDoubleClick += new MouseButtonEventHandler(myMap_MouseDoubleClick);  
      
            }  
      
            private void myMap_MouseDoubleClick(object sender, MouseButtonEventArgs e)  
            {  
                e.Handled = true;  
                Point mousePosition = e.GetPosition(this);  
                Location pinLocation = myMap.ViewportPointToLocation(mousePosition);  
                Pushpin pin = new Pushpin();  
                pin.Location = pinLocation;  
                pin.Content = counter += 1;  
                pin.MouseDown += new MouseButtonEventHandler(pin_MouseDown);  
                myMap.Children.Add(pin);  
                Pushpins.Add(pin);  
            }  
      
            private void pin_MouseDown(object sender, MouseButtonEventArgs e)  
            {  
                e.Handled = true;  
      
                var pushPinContent = 0;  
                var pushPin = sender as Pushpin;  
                if (pushPin != null & pushPin.GetType() == typeof(Pushpin))  
                    pushPinContent = Convert.ToInt32(pushPin.Content);  
      
                myMap.Heading = (double)pushPinContent;  
            }  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.