Silverlight - 如何实现地图
您将如何在 Silverlight 中实现这种类型的地图?地图将是交互式的,并且车站将是可点击的。
http://www.afn.org/~alplatt/tube.html
会你用混合画它吗?导入矢量图像?我想这个选择非常重要,因为寻路算法需要能够计算车站之间的距离/票价(基于它们的 XY 位置,大概还没有决定)。
只是寻找不同的想法和意见。
谢谢
How would you go about implementing a map of this type in Silverlight? The map would be interactive and stations would be clickable.
http://www.afn.org/~alplatt/tube.html
Would you draw it in blend? Import a vector image? I guess the choice is very important because pathfinding algorithms need to be able to calculate distances/fares between stations (based on their XY location, presumably, haven't decided yet).
Just looking for different ideas and opinions.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会采用矢量方法。将车站的 x,y 坐标和铁路线路径的控制点捕获为代码中的静态数据。为每个铁路线段和车站创建轻量级对象(不是用户控件),并让它们自行渲染并处理自己的鼠标单击。将铁路线定义为铁路段和车站的集合。
对于寻路,你最不想看到的就是使用像素来计算如何从 A 到 B。你只需要一棵表示站点之间连接的连接节点树,然后使用树遍历来查找两个站点之间的所有路径。对于数量有限的车站和路径,您还可以预先计算有效的车站组合和路径 - 就像火车时刻表一样。
I'd take the vector approach. Capture the x,y coordinates of the stations and the control points for the paths of the rail lines into static data in the code. Create lightweight objects (not UserControls) for each rail line segment and station, and let them render themselves and handle their own mouse clicks. Define a rail line as a collection of rail segments and stations.
For pathfinding, the last thing you want is to use pixels to figure out how to get from A to B. You only need a tree of connected nodes representing the connections between stations, then use tree traversal to find all paths between two stations. For a limited number of stations & paths, you could also precalculate the valid station combinations and paths - just like the train schedule tables.