Using the BingMapsDirectionsTask in Windows Phone Mango

Do you want to display the direction between 2 locations from your Windows Phone 7 Application ? If yes , BingMapsDirectionsTask launcher in the Windows Phone SDK might help you .

The BingMapsDirectionsTask launcher will launch the Bing Maps App on your Windows Phone and shows the driving direction between 2 points .

Using the BingMapsDirectionsTask in your Windows Phone App is easier .

Add reference to the System.Device assembkly to your Windows Phone Project and include the following namespaces .

using Microsoft.Phone.Tasks;
using System.Device.Location;

Create an instance of the BingMapsDirectionsTask and assign the start or end location for which you want to display the direction .

The start and the End properties of the BingMapsDirectionsTask accepts the values of type LabeledMapLocation . The LabeledMapLocation represents the geographic coordinate or the name .

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 Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
//using System.Device.Location;
namespace PhoneApp5
   public partial class MainPage : PhoneApplicationPage
     public MainPage()

     private void button1_Click(object sender, RoutedEventArgs e)
          BingMapsDirectionsTask Direction = new BingMapsDirectionsTask();
          LabeledMapLocation start = new LabeledMapLocation("Indiranagar , Bangalore", null);
          LabeledMapLocation End = new LabeledMapLocation("Koramangala , Bangalore", null);
          Direction.Start = start;
          Direction.End = End;


After setting the start and the end position , call the Show method of BingMapsDirectionsTask to launch the BingMap App .

This is what MSDN states about BingMapsDirectionsTask

“You can specify both the start and end points, or specify only one; in the latter case, the user’s current location is used for the other one. The start and end points contain a string label, and geographic coordinates specifying the latitude and longitude of the location. If you omit the geographic coordinates, the label string is used by the Bing Maps application as a search term.”



If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.


  1. Manoj November 20, 2011 Reply
    • Senthil Kumar November 20, 2011 Reply
  2. Anshul Agrawal March 26, 2014 Reply

Leave a Reply


Interesting BlogPosts to read

How to get an Enumerator from range of elements from ArrayList in C# ?
The code snippet shown in this blog post demonstrates how you can get the enumeraor from a range of ...
How to check for the column name in an SqlDataReader Object in C# ?
When working in ADO.NET for data access , there are times when you want to check to see if a column ...
Download - Pokemon Go for for Windows 10 (Third Party app)
Pokemon Go is one of the popular AR games for android and iOS devices and now , the game is made ava...