When you use the overview_path of the DirectionsResult, that's what you get: an overview. It is a reduced-waypoint polyline which is very useful for its purpose.
If you want to see the actual polyline, you need to drill down to the path array in the DirectionsStep object. http://code.google.com/intl/en/apis/maps/documentation/javascript/reference.html#DirectionsStep. Working through all the steps will get all points in the polyline. For your purpose, you might consider using the DirectionsStep (particularly the distance component) to determine the the lat-long of the "end" of your polyline (e.g., 1000 miles from LA), then display the overview_path up to that point. You'll still get the "corner cutting" on zoom, but your positioning will be accurate and you will get better performance (by not trying to draw a polyline with so many vertices). On Nov 24, 5:12 pm, Brent Taylor <[email protected]> wrote: > I would like to overlay the Polyline of a route obtained by the > Directions API with a second Polyline which shows the completed portion > of that route based on a specified distance (geolocation information is > not available). For example, if a user selects a route from Los Angeles > to New York, I would like to overlay the route with a Polyline which > represents the first 1000 miles of the route. > > So far, the best solution I've found is as follows. > > 1. Use the DirectionService API to obtain the DirectionResult for the > entire route. > 2. Obtain the route Polyline from the overview_path attribute of the > route and compute the distance between each point. > 3. Create a new Polyline which includes the subset of points (and a > newly calculated point) which represent the required distance. > > However, there are several problems with this algorithm due to the > limited number of points in the Polyline. > > 1. Since the Polyline represents only a subset of points related to the > route, the straight-line segments of the Polyline have a shorter total > distance than the actual distance specified with the leg attribute. > Since I know the ratio of the distances, I can compensate for this, but > the results cannot be entirely accurate. > 2. When the user zooms in on the composite map, the deviations of the > Polyline from the actual route become immediately evident. This is my > major concern. > > Is there another API available which might be more suitable for this > application? If not, is it possible to request a finer granularity of > points to be included in the overview_path? -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" 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-js-api-v3?hl=en.
