Search Results For : bingmapdirectiontasks

BingMapsDirectionsTask – Getting driving / walking directions

I was revisiting my old projects and reflecting on how I could improve on those products. I didn’t realised that there are so much we can do with the new Windows Phone APIs! I was looking at the MSDN’s Microsoft.Phone.Tasks Namespace and found out that there is a Bing Maps Direction Task Class now!

The first thing I thought of was the Green App project which I did during codeXtremeApps 2010 Its a Windows Phone 7 project where we direct our users to the nearest recyling bin around Singapore for them to recyle their waste product. There are more functions which I will not elaborate on here. I will be updating my project/portfolio page soon! I was playing with the Bing Maps Direction Task API just this afternoon. Thought it will be useful to post a tutorial on how to use it. 🙂 Should you face with any problems, feel free to contact me via the Contact Me form or email me at guohong@limguohong.com

Step 1 : Adding using Microsoft.Phone.Tasks and using System.Device.Location into references.

Bing Maps Directions Task 1 - Adding Reference

Bing Maps Directions Task 2 - Adding namespace

Step 2 :  Adding the Microsoft.Phone.Tasks and System.Device.Location into the project

Bing Maps Directions Task 3 - Adding namespace

Step 3 : Initialize a BingMapsDirectionsTask and create a start and end LabeledMapLocation . Note that start is optional. Should you not provide start location, the API will use the current location by default.

At the end of it, .Show() it and it will show the map.

BingMapsDirectionsTask Direction = new BingMapsDirectionsTask();

LabeledMapLocation start = new LabeledMapLocation(“Hougang Ave 4 919 Singapore , Singapore”, null);
LabeledMapLocation end = new LabeledMapLocation(“Paya Lebar Air Base, Singapore”, null);

Direction.Start = start;
Direction.End = end;

Direction.Show();

You can download a usage demostration of the class here. Source code included.

Please note that this is written for WP7.1

Bing Map Direction Task Demo Source Code Screenshot

Bing Map Direction Task Demo Source Code Screenshot

P.S: These 2 classes caught my attention, when I have some spare time, I will look into if I will be able to use it in my Slime Sweeper 2! ShareLinkTask class and Share Status Task Class!

If you have any questions, feel free to contact me via the contact form, comment or email me at guohong@limguohong.com

Do check out the tutorial page too!