How do I make a distance traveled Maps (yahoo/google) feature
I've been asked to make a feature that works with one of the popular map APIs. This feature would take a Start Point, End Point and a distance value and would generate a map showing the progress from the Start Point to the End Point.
For example, if the Start Point was Seattle, the End Point was Chicago and the distance value was 1000 miles, the map API would be used to create a map showing both Seattle and Chicago, with a line about 1/3rd of the way there.
Ideally, the mapping API used would be a publically available API available without cost. Seems easy, right? I'm not sure where to start. I would appreciate all input at this stage.







@Joshua I'm looking at the Yahoo AS3 map right now. It does look pretty clean.
@Fred There are a few examples of drawing line overlays on Yahoo and Google. They look pretty easy to implement, but I would prefer an actual route.
Ping me if you want to visit about it.
Either way, I think you will come to the same result. Here is a very high level look at what you will need to do.
You will have a set of line segments that form a polyline, loop over them in order until the sum of all parts is greater than the distance traveled. At which point you take the current segment calc the arc between points calc the point along the arc at the remainder of distance from the previous segment.
A couple things to consider:
When using lat/lng to calculate the distance between point you need to consider the curve of the earth, this is done with the Haversine Formula.
Depending on your final usage and the amount of data transmitted you should consider which side to store the entire route on, assuming you want to push/pull updates.
Consider using Google's PolyLine Encoder to keep the transfer size down, the encoder also has a utility for culling the line at increasing zoom levels. (you do not want to draw 600 polylines when zoomed out if you do not need to.
Many thanks,
Ben