Silverlight - how to implement a map
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.
精彩评论