Reputation: 907
In My Map Control, I want to move a bus through given bus stops. For that I have drawn route through given stops. Now I want to move the bus through this route. For a smoother rendering of bus through the path, I have to find multiple locations between start coordinates and end coordinates. And those locations should have road transportation. How can I achieve it? These are the four stops.
Geopath path = new Geopath(new List<BasicGeoposition>(){
new BasicGeoposition()
{
Latitude= 1.2989658333333334, Longitude=103.8004543333333
} ,
new BasicGeoposition()
{
Latitude=1.3027026666666668, Longitude=103.80124616666667
} ,
new BasicGeoposition()
{
Latitude=1.3062241666666665, Longitude=103.80175516666667
} ,
new BasicGeoposition()
{
Latitude=1.3087055, Longitude=103.8026675
}
}
);
Upvotes: 2
Views: 631
Reputation: 9763
You can use:
MapRouteFinder.GetDrivingRouteAsync(Geopoint, Geopoint)
Pass in the start and end location and it returns a MapRouteFinderResult object.
BasicGeoposition startLocation = new BasicGeoposition() {Latitude=47.643,Longitude=-122.131};
// End at the city of Seattle, Washington.
BasicGeoposition endLocation = new BasicGeoposition() {Latitude = 47.604,Longitude= -122.329};
// Get the route between the points.
MapRouteFinderResult routeResult =
await MapRouteFinder.GetDrivingRouteAsync(
new Geopoint(startLocation),
new Geopoint(endLocation),
MapRouteOptimization.Time,
MapRouteRestrictions.None);
The complete example can be found here:
https://learn.microsoft.com/nl-nl/windows/uwp/maps-and-location/routes-and-directions
Upvotes: 1