In addition to displaying a single point using the built-in Maps app, you can also display a route. The MapsDirectionsTask
class allows you to specify a start and end point for the route, as shown in the following example:
MapsDirectionsTask mapsDirectionsTask = new MapsDirectionsTask();
GeoCoordinate startCoordinate = new GeoCoordinate(47.635, -122.362);
mapsDirectionsTask.Start
= new LabeledMapLocation("Start Point", startCoordinate);
GeoCoordinate endCoordinate = new GeoCoordinate(47.650, -122.349);
mapsDirectionsTask.End = new LabeledMapLocation("End Point", endCoordinate);
mapsDirectionsTask.Show();
Note
If you do not specify a Start
value for the MapsDirectionsTask
, the phone’s current location is used.
If you provide a null GeoCoordinate
to the LabeledMapLocation
, for either the Start
or End
locations, the label parameter is used as a search term. For example, to display directions from the phone’s current location to the Space Needle in Seattle, you could use the following:
MapsDirectionsTask mapsDirectionsTask = new MapsDirectionsTask();
mapsDirectionsTask.End = new LabeledMapLocation("Space Needle", null);
mapsDirectionsTask.Show();
18.117.7.131