Google maps api how to draw direction line on travel route with ionic 3

I am trying to develop an android app with ionic framework , where
my location show in google map and the how moving the pointer is update,

and along with this

I need a direction line drawn on map from where I traveled ,after
that I click on stop then snapshot of the traveled route will mailed to
me (like UBER app).

I follow https://www.djamware.com/post/5a48517280aca7059c142972/ionic-3-angular-5-firebase-and-google-maps-location-tracking and this solves first part but now I stuck for second phase .please any body give some idea to achieve this.

I think the way is to use Directions Service - Google Maps JavaScript API

Some update on this?

I didn’t click the link you provided, so I’m not 100% on where you’re at. I’ve done something similar in an app a while back using the Spherical object and Polylines. I think (80% sure) I used the Google Distance Matrix as the last piece of the puzzle.

Other than that there’s not much I can say about actually making it happen. It was very complex. I’m not sure if anyone would be willing to go into it step by step without a paycheck at the other end! It was laborious.

with that example I tried but not getting accurate result.current location differ 30m-50m with map.and some times pointer point wrong location within 100m.so I am afraid is this actually work?