X90B: Bing Map Win Phone 7 Push Pins, fast and easy

Ok, got the poop from the pros in Redmond on how to work with pushpins, it’s easy.  But wait, I need to make it really hard to understand and confusing.  After all it seems like everyone who writes a blog about Win Phone 7 and bing maps must make it so confusing and difficult that NO ONE can possibly understand it who is less than a “300” level, whatever that is. (It is a rating that training centers give their class material.)

You can download my sample application from (link verified as of Nov. 15, 2010), this sample has the XAML Pages in it, but it needs work.


Thanks to Derrick Quan, the following code will get you working immediately, as long as you add pages to match the pages in the click events:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Device.Location;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Controls.Maps;

//Your project will have a different namespace, so make sure to change the “YourWinPhoneMapApplication”

namespace YourWinPhoneMapApplication

    public partial class MainPage : PhoneApplicationPage

        public MainPage()

            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

        void MainPage_Loaded(object sender, RoutedEventArgs e)
            Map map = new Map();
            map.CredentialsProvider = new ApplicationIdCredentialsProvider("Put your Bing Map API here");

            Pushpin pin1 = new Pushpin();
            pin1.Location = new GeoCoordinate(33.0, -117.0);
            pin1.Content = "1";
            pin1.MouseLeftButtonUp += new MouseButtonEventHandler(pin1_MouseLeftButtonUp);

            Pushpin pin2 = new Pushpin();
            pin2.Location = new GeoCoordinate(33.1, -117.0);
            pin2.Content = "2";
            pin2.MouseLeftButtonUp += new MouseButtonEventHandler(pin2_MouseLeftButtonUp);

            Pushpin pin3 = new Pushpin();
            pin3.Location = new GeoCoordinate(33.2, -117.0);
            pin3.Content = "3";
            pin3.MouseLeftButtonUp += new MouseButtonEventHandler(pin3_MouseLeftButtonUp);

            Pushpin pin4 = new Pushpin();
            pin4.Location = new GeoCoordinate(33.3, -117.0);
            pin4.MouseLeftButtonUp += new MouseButtonEventHandler(pin4_MouseLeftButtonUp);
            pin4.Content = "4";

            map.SetView(LocationRect.CreateLocationRect(pin1.Location, pin2.Location, pin3.Location, pin4.Location));

        void pin1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            NavigationService.Navigate(new Uri("/YouMakeThisPage1.xaml", UriKind.Relative));

        void pin2_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            NavigationService.Navigate(new Uri("/Youmakeanotherpage.xaml", UriKind.Relative));

        void pin3_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            NavigationService.Navigate(new Uri("/Andanotherpagemadebyyou.xaml", UriKind.Relative));

        void pin4_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            NavigationService.Navigate(new Uri("/Aforurthpagemadebyyou.xaml", UriKind.Relative));



That’s it, end of secret communications, for the 5 or 6 people who are reading this blog, I hope you share it with people you know.


Comments (1)

  1. Jayson says:

    with  icon ?????