'Google mixed polyline and direction

I'm trying to build an app for building a route with Google Maps. I need to combine Google's direction service and Google's polylines. The route could consist only of direction, or polyline. It could also be a special route built by parts of directions and polylines. For example:
Route contains 9 points/markers (A-I) and 4 parts:

ABC - directions from A to C (B is waypoint)
CDE - polyline C-D-E
EFG - one more direction from E to G (F is waypoint)
GHI - polyline of G-H-I

C, E, G - are turning points of directions and polylines

Route builds step-by-step from point A to point I. Building of direction or polyline depends on external flag/variable. Every point is displayed as a marker. Every marker of route should be editable (draggable), and not dependent on other route parts.
When a marker for the direction's waypoint changes then the direction part of the whole route should be recalculated (previous and next polylines should stay as before).
When a marker of polyline's waypoint changes then the polyline part of theroute should be redrawn (previous and next directions should stay as before).
When a marker turning point changes then the polyline's point changes its position and recalculates directions.

I'm looking for the best way for implementation, but I'm already out of ideas.

PS.
when I say direction - I mean http://goo.gl/1umeBG
when I say polyline - I mean http://goo.gl/mdTHRD



Solution 1:[1]

I found how to build it. All sources available at https://bitbucket.org/dunice-zlidnev/mixed_routes/ (pretty simple design, just the base)
Feel free to use.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Valentin