【发布时间】:2018-03-30 19:47:32
【问题描述】:
我有地图控制:
<wpf:Map x:Name="EventMapBing" CredentialsProvider="MY API" MouseDoubleClick="EventMapBing_MouseDoubleClick">
我知道如何获取整条路线:
private void GetResponse(Uri uri, Action<Response> callback)
{
WebClient wc = new WebClient();
wc.OpenReadCompleted += (o, a) =>
{
if (callback != null)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Response));
callback(ser.ReadObject(a.Result) as Response);
}
};
wc.OpenReadAsync(uri);
}
并获取数据:
string from = "gdansk";
string to = "sopot";
string query =
string.Format(
"https://dev.virtualearth.net/REST/V1/Routes/Driving?wp.0={0}&wp.1={1}&optmz=distance&routeAttributes=routePath&key=MYAPI",
from, to);
Uri geocodeRequest = new Uri(query);
GetResponse(geocodeRequest, (x) =>
{
var route = x.ResourceSets[0].Resources[0] as Route;
var wholeRoute = route.RouteLegs;
// x.ResourceSets[0].Resources[0].
});
所以我的“wholeRoute”变量是 RouteLeg[] 类型。如何在我的 bing 地图控件上显示该路线?
【问题讨论】:
-
看看这个。那里有指向其他帖子和至少一篇文章的链接。我没有深入研究它,但我认为所有这些中的某个地方应该是相关的。 social.msdn.microsoft.com/Forums/en-US/…
-
@Andy 谢谢,这真的很有帮助!现在一切正常。