We got acquainted with Launchers in our previous topic. Let us now look at BingMapsDirectionsTask
, and use it to provide driving directions from within our application:
HelloMaps-Pushpin
project and rename it HelloMaps-Directions
. MainPage.xaml.cs
file and import the Microsoft.Phone.Tasks
namespace into your project.using Microsoft.Phone.Tasks;
myDrivingDirection
of type BingMapsDirectionsTask
as:BingMapsDirectionsTask myDrivingDirection;
MainPage()
constructor, we define the start and end points of our route. The start being some location near Redmond and end being Mercer Island.// Show driving directions to Mercer Island // Use "null" as the starting location to use your current // location as the starting point. myDrivingDirection = new BingMapsDirectionsTask(); myDrivingDirection.Start = new LabeledMapLocation ("My Location", newGeoCoordinate(47.6601, -122.13333)); myDrivingDirection.End = new LabeledMapLocation ("Mercer Island", null); // End of driving directions
start()
method of the BingMapsDirectionsTask
instance.private void hyperlinkButton1_Click(object sender, RoutedEventArgs e) { myDrivingDirection.Show(); }
Pretty simple, huh? It is that easy to incorporate directions in your apps no more extensive SDKs, libraries, and tons of code to import within your app. In pure Windows folklore we would say "Plug and Play" directions. You can find this example project in the code files for the book under Chapter 3
, titled HelloMaps-Directions
.
18.216.143.65