At IdentityMine, we had the chance to develop a few applications featuring the new Windows Phone 7 features coming up in the update codenamed “Mango”. This series will showcase a few of the new features included in Mango that we used in those apps.
Part 2: Starting a Bing Maps navigation
Windows Phone 7 Mango features turn by turn navigation with voice guidance directly integrated in the Bing Maps application. At the time of writing, it is still unclear exactly which countries will be supported. However, for the supported countries (such as the USA), an application can easily start a Bing Maps navigation.
In order to use the GeoCoordinate class or any other location-related feature in your app, you need to add a reference to the System.Device assembly. The class itself is located in the System.Device.Location namespace.
How to start a navigation?
Like most interactions between an application and the operating system, this starts with a task: the BingMapsDirectionsTask class.
Start a new navigation takes two locations: a Start and an End. The code looks like this:
var bingMapsDirectionsTask = new BingMapsDirectionsTask(); var end = new LabeledMapLocation( "Shop #1234", shopGeocoordinate); var start = new LabeledMapLocation( "My location", myGeoCoordinate); bingMapsDirectionsTask.Start = start; bingMapsDirectionsTask.End = end; bingMapsDirectionsTask.Show();
In the code above, the shopGeocoordinate and the myGeocoordinate are two instances of the GeoCoordinate class, where the Latitude and Longitude properies are set. Note that the phone’s own location can be obtained by using a GeoCoordinateWatcher instance, as described on MSDN.
After the Show method is called on the bingMapsDirectionsTask, the application is put in the background and the Bing Maps application starts. The rest is handled by this application, including turn by turn navigation and voice guidance.
Having a GPS in a phone is something I (as a geek) am still not completely over. The possibility to leverage the integrated navigation capabilities instead of having to implement a custom solution is making this task not only much easier, but also a more consistent user experience.
However, the feature relies on Bing Maps, which as we all know by now is not very good outside of the US. Let’s hope that the Nokia deal will improve this service very soon (since Nokia has probably the best worldwide database of maps, location information and POIs (at the exception maybe of Garmin).