我正在开发一个带有地图功能的UWP应用程序。 我有Rout绘图功能,我在这个功能中遇到了问题。
这是我的代码(在WP 8.1中完全正常运行)
public async Task DrawRouteOnMap(double StartLong, double StartLat, double EndLong, double EndLat)
{
// Start at Grand Central Station.
BasicGeoposition startLocation = new BasicGeoposition();
startLocation.Latitude = StartLat;
startLocation.Longitude = StartLong;
Geopoint startPoint = new Geopoint(startLocation);
// End at Central Park.
BasicGeoposition endLocation = new BasicGeoposition();
endLocation.Latitude = EndLat;
endLocation.Longitude = EndLong;
Geopoint endPoint = new Geopoint(endLocation);
// Get the route between the points.
MapRouteFinderResult routeResult =
await MapRouteFinder.GetDrivingRouteAsync(
startPoint,
endPoint,
MapRouteOptimization.Distance,
MapRouteRestrictions.None,
290);
if (routeResult.Status == MapRouteFinderStatus.Success)
{
// Use the route to initialize a MapRouteView.
MapRouteView viewOfRoute = new MapRouteView(routeResult.Route);
viewOfRoute.RouteColor = Windows.UI.Color.FromArgb(1, 43, 151, 71);
viewOfRoute.OutlineColor = Windows.UI.Color.FromArgb(1, 43, 151, 71);
//await new Windows.UI.Popups.MessageDialog(viewOfRoute.Route.EstimatedDuration.ToString()).ShowAsync();
// Add the new MapRouteView to the Routes collection
// of the MapControl.
mapControl.Routes.Add(viewOfRoute);
// Fit the MapControl to the route.
await mapControl.TrySetViewBoundsAsync(
routeResult.Route.BoundingBox,
null,
MapAnimationKind.Linear);
}
}
此代码的结果是
StartPointNotFound
我也尝试了一个没有希望的静态位置。
提前致谢