EziData Solutions

Web, NET and SQL Server

WP7 Mango Features #2: BingMapsDirectionTask

In the previous post I covered the new Bing Maps Tasks available to developers in the Mango release for Windows Phone. In that post I showed you how to use the search task to located business or point of interest matching your search term. In this post we will cover the other new feature, the BingMapsDirectionTask. Again this is a huge time-saver for anyone who has ever tried to use the Bing Maps API and built a ‘get directions’ page from scratch. 

Follow the instructions in the previous post to get started. Once you have all the references sorted, create a new button and code its OnClick event to the following. 

The BingMapsDirectionsTask requires either the start or end location to be explicitly set, and it will use the device location for the one you do not specify. Of course in the emulator, you will want to set both values.

As with the BingMapsTask, you only require a few lines of code to gain access to all the goodness of the built-in Bing Maps application.

private void Button_Click(object sender, RoutedEventArgs e)


    BingMapsDirectionsTask directions = new BingMapsDirectionsTask();

    //your must specify either the start or end locations

    //if you leave one of these empty, Bing will use the current location

    //if using the emulator simply specify both start and end

    directions.Start = new LabeledMapLocation("Home", new GeoCoordinate(-27.31063, 152.99032));

    directions.End = new LabeledMapLocation("Work", new GeoCoordinate(-27.46868, 153.02105));





One interesting thing I noticed after accidently swapping a few numbers in the Start lat/long was that I ended up on Stradbroke Island. Not deterred by my error, Bing actually directed me to the ferry terminal and even included a helpful message ‘check the timetable’.

Posted: Sep 01 2011, 06:02 by CameronM | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: WP7