在 Bing Maps 控件上计算并绘制路线
在我的 WP7(mango) 应用程序中,我需要将用户从一个点导航到另一点。我知道有一个地图控件可以让你在上面绘制人员,但是你如何让它为你绘制路径呢? (基于指定的目的地和用户的当前位置 - 但这不断变化,所以如果他走了,你如何更新路线?)
in my app for WP7(mango) I need to navigate the user from one point to another. I know there is the Map control that lets you draw staff on it, but how do you ask it to draw the path for you? (based on the specified destination & user's current location - but that keeps changing so how do you update the route if he goes of the way?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使用用户当前位置更新地图,请使用
GeoCooperativeWatcher
并在数据绑定图钉发生变化时更新其位置。请记住将最小距离设置为较低的值,例如 5 米。可以使用此 XAML 模板创建类似于 bing 地图上的图钉:
可以使用 Bing 地图获取地址的地理坐标。您可以在此处阅读有关 Bing 服务的更多信息:http://msdn.microsoft.com/en-us/library /cc980922.aspx -- 您需要的是 GeoCodeService
绘制路径相当复杂,特别是如果您希望它沿着道路行驶。为此,您需要 Bing 地图路线服务。
将服务添加到 Visual Studio,并使用
RouteServiceReference
作为名称,然后您可以使用以下代码来获取路径片段,并将它们添加到您的地图中。下面的 XAML 反映了我将片段添加到的控件:相关 XAML:
To update the map with the users current location, use the
GeoCoordinateWatcher
and update the position of a databound Pushpin as it changes. Remember to set the minimum distance to something low, like 5 meters.A pushpin like the one on bing maps, can be created with this XAML template:
Getting the GeoCoordinate of a address can be done with Bing Maps. You can read more about Bing Services here: http://msdn.microsoft.com/en-us/library/cc980922.aspx -- the one you need is the GeoCodeService
Drawing a path is rather complicated, specially if you want it to follow the roads. For this, you need the Bing Maps Route Service.
Add the service to Visual Studio, with
RouteServiceReference
as name, and then you can utilize following code to get the path fragments, and add them to your map. The XAML below reflects the controls I add the fragments to:Related XAML: