in the upcoming “Mango” update for Windows Phone 7, Microsoft has already released the Windows Phone Developer Tools Beta 2 for this new version which has got version number 7.1.
One of the new cool features which is included in this beta release is the support to use the “Directions” feature in Bing Maps from your app. This feature makes it very easy to make a location aware app and makes it interactive to the user to help him find a specific spot. (Think about an app that helps users find only your restaurants, ATM’s, your company or anything else that has a coordinate)
Please note that I’m trying to keep away from the “integrate” part, cause actually it’s not integrating but more like navigating away from your app to Bing Maps with the location you specified in your app.
Okay, bring on this new feature and show us how to do this.
First, let’s start with the introduction of this feature/class/task or how you want to call it. We are talking about the BingMapsDirectionsTask which is a very simple class that lives in the Microsoft.Phone.Tasks namespace. You can use this task to create a route on Bing Maps from your app. In short terms this class has three important objects (2 properties / 1 method). It has a Start and an End property, and a method Show() which is it.
In general below code will be enough to create a route on the Bing Maps app:
1 BingMapsDirectionsTask directionTask = new BingMapsDirectionsTask(); 2 directionTask.Start = new LabeledMapLocation("Start", new GeoCoordinate(52.512794, 6.091539)); 3 directionTask.End = new LabeledMapLocation("End", new GeoCoordinate(52.512794, 6.091539)); 4 5 directionTask.Show();
Just three lines of code. Can it be easier?
Yes it can!
If you don’t assign a value to the start property than it will automatically take your location and calculate a route to your End location.
I have created a sample solution where you can use the locations from the emulator to specify a start location and when you click on the map it will take your position (which is set by the emulator) and calculate a route to the location you have clicked.
Choose a location by using the Additional tools.
And there it is our own created direction in the Bing Maps app.
To be honest I’m a bit in doubt about what I think about this feature. On one side it’s a very handy, easily to implement feature that will give you navigation/routing to your location in minutes.
Another thought I still have is I’m adding a map control to my app, a user clicks around and if it needs to calculate a route it exits my app, and starts Bing Maps. No real integration.
Anyone having some thoughts about it?