开发者

Silverlight - how to implement a map

开发者 https://www.devze.com 2022-12-27 08:00 出处:网络
How would you go about implementing a map of this type in Silverlight? The map would be interactive and stations 开发者_StackOverflow社区would be clickable.

How would you go about implementing a map of this type in Silverlight? The map would be interactive and stations 开发者_StackOverflow社区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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消