This reason for this behavior is that all map data in China is shifted by a government mandated algorithm. This has been solved now.
Unexpected restult when querying walking route
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?
1 additional answer
Sort by: Most helpful
-
IoTGirl 3,051 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