Some time we need to show direction between two points. For this we use Google Map or Bing Map or Yahoo Map and So on. But, When your creating application in Windows Phone it is best to go with Bing Maps. We no need to write more lines also. Just we need to open Bing Map app from Our application with few lines of code.
This Bing map is more interactive too. We will get step by step direction guide on go. I like the way they show me a promote saying don’t look at Phone when you’re in drive, take help from passenger .
We can set start point and end point, so it will display directions between that points. If you did not point start point, by default it will take current location (Your location, get using GPS). from that location it will display the direction to end point.
GeoCoordinate endLocation = new GeoCoordinate(16.0009, 80.0000);
LabeledMapLocation endPointML = new LabeledMapLocation("END Location Name", endLocation);
If we did not pass GeoCoordinate as a parameter, it will open the suggestion list. user can select for the list.
Here is the full code.
Note:- we must add
System.Device.dll to our project
Write this below code when user click on button or where you want to open Bing Maps Directions..
BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
// Here is Start point
//GeoCoordinate chennaiAirportLocation = new GeoCoordinate(12.9825, 80.1644);
//LabeledMapLocation startPointML = new LabeledMapLocation("Chennai Airport", chennaiAirportLocation);
//Here is End point
GeoCoordinate vijayawadaLocation = new GeoCoordinate(16.5009, 80.6553);
LabeledMapLocation endPointML = new LabeledMapLocation("Vijayawada", vijayawadaLocation);
/*With out Geo-coordinate, So, it will */
//LabeledMapLocation endPointML = new LabeledMapLocation("shopping mall", null);
// If Start is not set, the user's current location is used as the start point.
//bingMapsDirectionsTask.Start = startPointML;
bingMapsDirectionsTask.End = endPointML;
in this above code I did not start point. you can remove those comment lines and try by setting start point. Remember, if we did not set start point it will take users current location using GPS.
Enjoy while coding..!