在“我的地图控件”中,我想将公交车移动到给定的公交车站。为此,我画出了经过指定站点的路线。现在,我要沿着这条路线移动公共汽车。为了使路径上的公交车更流畅,我必须在起点坐标和终点坐标之间找到多个位置。那些地方应该有公路运输。我该如何实现? 这是四个站。
Geopath path = new Geopath(new List<BasicGeoposition>(){
new BasicGeoposition()
{
Latitude= 1.2989658333333334, Longitude=103.8004543333333
} ,
new BasicGeoposition()
{
Latitude=1.3027026666666668, Longitude=103.80124616666667
} ,
new BasicGeoposition()
{
Latitude=1.3062241666666665, Longitude=103.80175516666667
} ,
new BasicGeoposition()
{
Latitude=1.3087055, Longitude=103.8026675
}
}
);
答案 0 :(得分:1)
您可以使用:
MapRouteFinder.GetDrivingRouteAsync(Geopoint, Geopoint)
传入起点和终点,并返回一个MapRouteFinderResult对象。
BasicGeoposition startLocation = new BasicGeoposition() {Latitude=47.643,Longitude=-122.131};
// End at the city of Seattle, Washington.
BasicGeoposition endLocation = new BasicGeoposition() {Latitude = 47.604,Longitude= -122.329};
// Get the route between the points.
MapRouteFinderResult routeResult =
await MapRouteFinder.GetDrivingRouteAsync(
new Geopoint(startLocation),
new Geopoint(endLocation),
MapRouteOptimization.Time,
MapRouteRestrictions.None);
完整的示例可以在这里找到:
https://docs.microsoft.com/nl-nl/windows/uwp/maps-and-location/routes-and-directions