Unexpected Error with MapRouteFinder in UWP App

Lokender Tiwari 0 Reputation points
2025-07-29T10:24:09.75+00:00

Encountering an issue with the Bing Maps in a Microsoft UWP app when attempting to render a path. An "Unspecified error" is returned when passing the following four waypoints to the Bing Maps API via the GetDrivingRouteFromEnhancedWaypointsAsync method from the Windows.Services.Maps library:

  • 42.029832,-87.683389
  • 41.92209,-87.64922
  • 41.903669,-87.65712
  • 41.889947,-87.630301

Here’s the relevant C# code snippet:

for (int index = 0; index < LocationList.Count; index++)
{
        BasicGeoposition point = new BasicGeoposition() { Latitude = item.Latitude, Longitude = item.Longitude };
        path.Add(new EnhancedWaypoint(new Geopoint(point), WaypointKind.Via));
}

MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteFromEnhancedWaypointsAsync(path, new MapRouteDrivingOptions()
{
    RouteOptimization = MapRouteOptimization.Distance,
    RouteRestrictions = MapRouteRestrictions.Ferries
});

Any insights on resolving this issue would be appreciated.

Developer technologies | Universal Windows Platform (UWP)
{count} votes

4 answers

Sort by: Most helpful
  1. Harry Vo (WICLOUD CORPORATION) 405 Reputation points Microsoft External Staff
    2025-07-30T03:54:43.3233333+00:00

    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 and item.Longitude, but I don't see item 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 as Stop. If all points are marked as Via, 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!

    0 comments No comments

  2. Lara 20 Reputation points
    2025-07-30T09:13:49.2366667+00:00

    It’s possible this issue occurs due to missing capabilities in the manifest or invalid coordinates being passed.

    Make sure you've added the following capability in your Package.appxmanifest:

    <Capability Name="location" />

    Also check if the latitude and longitude values used in Geopoint are valid. Invalid coordinates can sometimes cause MapRouteFinder to throw unexpected errors.

    Hope this helps!


  3. Starry Night 30 Reputation points
    2025-08-12T07:05:03.84+00:00

    From the official document MapRouteFinder Class, we could know that

    The UWP MapControl and map services from the Windows.Services.Maps namespaces rely on Bing Maps. Bing Maps for Enterprise is deprecated and will be retired, at which point the MapControl and services will no longer receive data.

    And from document Getting Started with Bing Maps, we also find that:

    Bing Maps for Enterprise is deprecated and has been retired for all free (Basic) account customers. Enterprise account customers can continue to use Bing Maps for Enterprise services until June 30th, 2028. To avoid service disruptions, all enterprise account customers using Bing Maps for Enterprise REST APIs and SDKs will need to be updated to use Azure Maps by June 30th, 2028.

    So, since the MapRouteFinder Class from the Windows.Services.Maps namespaces is deprecated , we do not recommend that you continue using it. You can try to use Azure Maps instead.

    0 comments No comments

  4. Lokender Tiwari 0 Reputation points
    2025-08-12T09:18:52.19+00:00

    MapRouteFinder Class start giving response. We can close the ticket

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.