Hi @Lokender Tiwari ,
My name is Harry, Support Engineer who specialize in UWP (Universal Windows Platform). Thank you for reaching out on Microsoft Q&A!
After reading your code, I found that you had made some mistakes:
- In your loop, it looks like you're referencing
item.Latitude
anditem.Longitude
, but I don't seeitem
within the loop. Have you declared it?
for (int index = 0; index < LocationList.Count; index++)
{
var item = LocationList[index]; //Did you define the 'item'?
BasicGeoposition point = new BasicGeoposition()
{
Latitude = item.Latitude,
Longitude = item.Longitude
};
path.Add(new EnhancedWaypoint(new Geopoint(point), WaypointKind.Via));
}
- Also in this loop, the
EnhancedWaypoint
API expects at least two waypoints - Start and End - to be marked asStop
. If all points are marked asVia
, the routing engine doesn't know where to begin or end the route
for (int index = 0; index < LocationList.Count; index++)
{
...
//You are adding every point as 'WaypointKind.Via' which is incorrect.
path.Add(new EnhancedWaypoint(new Geopoint(point), WaypointKind.Via));
}
Instead, make the first and last point as 'Stop', and the rests are 'Via'
for (int index = 0; index < LocationList.Count; index++)
{
...
WaypointKind kind = (i == 0 || i == LocationList.Count - 1) ? WaypointKind.Stop : WaypointKind.Via;
path.Add(new EnhancedWaypoint(new Geopoint(point), kind));
//(You can read the document below for more detail)
}
Although Bing Maps is still available in UWP in the next few years, it is recommended to upgrade your app using Azure Maps for a long-term support! However, since Azure Maps does not have a native UWP SDK, you can access it via REST APIs or WevView2 control with WinUI 2.
You can also find relate documentations here:
Display routes and directions on a map - UWP applications | Microsoft Learn (There is an example that uses a via
waypoint in between two stop
waypoints)
Migrate from Bing Maps to Azure Maps overview (A basic tutorial on how to migrate to Azure Maps)
I hope this helps you get things back on track quickly! If you agree with our suggestion, feel free to interact with the system accordingly!