You could use the directionsService to get the total distance from
LatLng x to destination.  If you are currently using the
directionsService to display the total route, you'll need another
instance of the directionsService to do your distance-to-go
calculation.

If your total route is just a single leg, then you're in luck.  With
my luck, I'd have to use several internal waypoints to get the
directionsService to pick the route that I was using (as it would not
be what google picks as the shortest route).  For your distance
calculation, you'd use the same internal waypoints, but you'll have to
drop them one by one as you go past them (otherwise you'll
backtrack).  The difficulty of doing this depends a little on how
complex your route is; if it's mostly a straight line, it's not too
hard to tell when you've passed a waypoint.

It all depends on your use case.

- jeff

On Aug 23, 9:55 am, troot <tro...@gmail.com> wrote:
> Hi,
>
> I'm doing a site for charity. It will have a map with a route on it. We have
> a device that will update a db with gps coordinates as the event proceeds.
>
> I can put a marker onto the map handy enough.
>
> What I'm looking to do though, is get the marker to update with the distance
> remaining to reach the destination. Does anyone know how I
> might achieve this?
>
> I'm looking for a function that will allow me to kinda say: "if marker is at
> LatLng x, what distance is it from destination Y along route Z"
>
> If I try to insert it as a waypoint, it mucks up the route.
>
> Any thoughts?
>
> Cheers
> Troot

-- 
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 google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to