Unexpected restult when querying walking route

Roy 96 Reputation points
2021-09-10T06:29:42.603+00:00

Hi everyone,

I am trying to use the route function of the Bing map (Wuxi - Shanghai) . When I tried to find the route data when calling MapRouteFinder.GetWalkingRouteAsync() Method, the MapRouteFinderResult is giving me a NoRouteFoundWithGivenOptions status.

To confirm if this issue is related to the location, I tried to get some other route data like New York to San Francisco, or The White House to Statue of Liberty National Monument. But the MapRouteFinderResult failed again and it gives me the StartPointNotFound status.

This is the code I'm using

private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {

            BasicGeoposition cityPosition = new BasicGeoposition() { Latitude = 31.2304, Longitude = 121.4737 };
            Geopoint cityCenter = new Geopoint(cityPosition);

            MapControl1.Center = cityCenter;
            //other information
            MapControl1.ZoomLevel = 11;
            MapControl1.LandmarksVisible = true;
            Geopoint MyLoc = null;
            var accessStatus = await Geolocator.RequestAccessAsync();

            switch (accessStatus)
            {
                case GeolocationAccessStatus.Allowed:
                    Geolocator geolocator = new Geolocator();
                    Geoposition pos = await geolocator.GetGeopositionAsync();
                    //get my position
                    MyLoc = pos.Coordinate.Point;
                    break;
                case GeolocationAccessStatus.Denied:
                    break;
                case GeolocationAccessStatus.Unspecified:
                    break;
            }
            MapIcon mapIcon1 = new MapIcon();
            mapIcon1.Location = cityCenter; 
            mapIcon1.NormalizedAnchorPoint = new Windows.Foundation.Point(1.0, 1.0);
            mapIcon1.Title = "万达";
            mapIcon1.ZIndex = 0;
            mapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/StoreLogo.png")); 
            MapRouteFinderResult routeResult = await MapRouteFinder.GetWalkingRouteAsync(MyLoc, cityCenter); 


            if (routeResult.Status == MapRouteFinderStatus.Success)
            {
                double length = routeResult.Route.LengthInMeters;
                //distance
                string Tb_Distance = length < 1000 ? length.ToString() + "m" : (length / 1000).ToString("0.00") + "km";
                //time
                string Tb_Time = routeResult.Route.EstimatedDuration.TotalMinutes.ToString("0.00") + "分钟";

                //show the route
                MapRouteView viewOfRoute = new MapRouteView(routeResult.Route);
                viewOfRoute.RouteColor = Windows.UI.Color.FromArgb(255, 26, 188, 156);
                MapControl1.Routes.Clear();
                MapControl1.Routes.Add(viewOfRoute);
                await MapControl1.TrySetViewBoundsAsync(
                routeResult.Route.BoundingBox,
                null,
                Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None);
            }
        }

Question:

Why I can't get the correct route data? Is there something I'm missing?

Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
245 questions
{count} votes

1 additional answer

Sort by: Most helpful
  1. IoTGirl 2,976 Reputation points Microsoft Employee
    2021-09-18T00:31:37.303+00:00

    Hi Roy,

    Further to Duncan's answer, if you put that same location in the consumer page at Bing.com/maps, what happens? Does the location look "Routeable"? Did Bing Maps change your location to move it to a nearby spot to accommodate? Can you get the expected route to work in the Bing Maps consumer experience?

    Sincerely,
    IoTGirl