2
votes

I am a newbie I have a database with addresses and longitude/ lattitude data. I want to write a small windows application that is able to put multiple pushpins or other marks on the map using longitude and lattitude-

  1. The user types ind the address
  2. The system gets the longitude and laittude and adds the pushpins on the map. I really need some help and guidance to get started. I can manage th database call and gui stuff, but i havent been able to successfully adding a bing map and set the pushpins in a simple winform application yet. Im using visual studio 2012 I have downloaded and installed the Bing Maps WPF control
1

1 Answers

2
votes

So adding a map to a wpf app is super easy. Following the steps here: https://msdn.microsoft.com/en-us/library/hh745791.aspx

I'll quickly go over the steps mentioned in the article:

Step 1. You have already completed since you have the Bing Maps WPF control. Step 2. Get a Bing Maps Key Step 3. Add the xmlns:m annotation to your Window xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF" Step 4. Add a maps Control to your Window. It will be nested within something like the Like this

<Grid>
    <m:Map x:Name="myMap"
        CredentialsProvider="Your Key From Step 2"/>
</Grid>

Step 5. In your Code behind, add pins to your map

        public MainWindow()
    {
        InitializeComponent();
        Pushpin pin = new Pushpin();
        pin.Location = new Location(37.1481402218342, -119.644248783588);

        // Adds the pushpin to the map.
        myMap.Children.Add(pin);

        // Removes pushpin from the map.
        // myMap.Children.Remove(pin);
    }