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.”



3 thoughts on “Using the BingMapsDirectionsTask in Windows Phone Mango

  1. 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?

  2. 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 Reply

Your email address will not be published. Required fields are marked *