Wasn't it jameslove who wrote:

>Why not get the Google API to calculate the distance? I want to avoid
>having Google calculate the distance since that would involve numerous
>calls to the API and be sluggish. Am I wrong in thinking this?

If you mean making a GDirections call every time the mouse moves, then
that would be sluggish. There's a GDirections speed limit of about 3 or
4 per second.

Looping along the poly doing .getVertex() and .distanceFrom()s should be
fast enough.

>The approach I I'm thinking about is as follows: I will display the
>polyline and dump the polyline nodes into an array. When the marker is
>over the polyline, I determine which nodes of the polyline the marker
>is between and calculate the distance from the node closest to the
>starting node using the lat/lon. I will then calculate the distance
>from the closest node to the starting node and add the values. The
>result is then displayed.

It's not entirely obvious how to determine which segment of the polyline
contains the point. Even with routes that don't have U-turns or have
off-ramps that loop back to cross underneath the main roadway there are
often situations where the point isn't contained by the two nearest
vertices. Consider this scenario:

   A
   |
   |
   B---------*-------------------------------------C

The two nearest vertices are A and B, but the * actually lies on segment
BC.

-- 
http://econym.googlepages.com/index.htm
The Blackpool Community Church Javascript Team


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to