I'd recommend the trial and error approach, dividing the polyline in two each search, and then divide the next segment in two based on whether the new point is less than or greater than that time away from p2. Once you're close enough, stop. You will have to wait in your loop to prevent GDirections attempts coming too close together, but since each search cuts out half your remaining polyline it should be doable within maybe 10 passes at most (that gives an accuracy of 1/1024 of your polyline). That can be done within a few seconds no problem. I think waiting 200ms between requests is plenty.
The other option is to get closer based on guessing the spot by assuming a constant speed, and then test. That might be a bit more accurate, but would be more complicated. You would update the estimated speed for each segment and continue refining based on the amount of time needed for each segment. I'd go with the easier binary search personally, though doing the refined method would be elegant. Would love to see it if you do! -Brian
-- You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.
