There's nothing in the API that will help with that. You'd have to write 
your own direction finder.

A bus route direction finder is easier to write than a general purpose 
route finder because you have a much smaller set of nodes, the bus 
stops, where the route can change. If your city isn't too large, it's 
feasible to perform a brute force search.

Allocate a "cost" to travelling each segment of bus route, from one stop 
to the next. GDirections uses estimated elapsed time as the cost, but 
you can use whatever you want to minimise. In particular, it would make 
sense to add a high cost factor to changing busses, so that your system 
would prefer a longer route with one change of bus to a shorter route 
which involved two changes. It would also make sense to include the 
frequency of the busses on the route, so that your system would prefer a 
longer route that involved a bus that runs every 10 minutes to a shorter 
route where there's only one bus per hour.

Once you've created your "cost" metric, and assigned costs to each 
segment, assign a cost of zero to the destination node and Infinity to 
all the others.

Repeat:
  Find the unprocessed node with the lowest cost, call it node A.
  Loop through all the nodes (B) that are one segment away from node A.
  Calculate their costs via this route by adding the cost of the segment
     to the cost of node A.
  If this cost is less than the previous cost assigned to node B, assign
     node B that cost, and record that the route goes via node A.
  Mark node A as processed.
Until: the start node is the unprocessed node with the lowest cost.

At that point you have the route from start to destination that gives 
the lowest cost.

-- 
Mike Williams
http://econym.org.uk/gmap



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