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.
Like it? Share it!

3 Comments so far. Feel free to join this conversation.

  1. Manoj November 20, 2011 at 4:50 am - Reply

    Error 1 The best overloaded method match for ‘Microsoft.Phone.Tasks.LabeledMapLocation.LabeledMapLocation(string, System.Device.Location.GeoCoordinate)’ has some invalid arguments c:\users\manoj\documents\visual studio 2010\Projects\bingmas\bingmas\MainPage.xaml.cs 30 36 bingmas

    Error 2 Argument 2: cannot convert from ” to ‘System.Device.Location.GeoCoordinate’ c:\users\manoj\documents\visual studio 2010\Projects\bingmas\bingmas\MainPage.xaml.cs 30 82 bingmas

    i get these errors..where am i going wrong?

    • Senthil Kumar November 20, 2011 at 8:28 pm - Reply

      Looks like you are passing empty string to the 2nd parameter … GeoCoordinate

  2. Anshul Agrawal March 26, 2014 at 8:59 pm - Reply

    Well, what to do if i want to provide only end coordinates and not the name of the location since it is unknown to me. Something like this

    LabeledMapLocation spaceNeedleLML = new LabeledMapLocation(“”, coordinates);

    I have coordinates only and not the label.

Leave A Response